diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/IXLPivotField.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/IXLPivotField.cs index 4fce6d6..8e69e8b 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/IXLPivotField.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/IXLPivotField.cs @@ -27,7 +27,7 @@ String SourceName { get; } String CustomName { get; set; } - XLSubtotalFunction Subtotals { get; set; } + List Subtotals { get; } Boolean IncludeNewItemsInFilter { get; set; } XLPivotLayout Layout { get; set; } @@ -39,7 +39,7 @@ IXLPivotField SetCustomName(String value); - IXLPivotField SetSubtotals(XLSubtotalFunction value); + IXLPivotField AddSubtotal(XLSubtotalFunction value); IXLPivotField SetIncludeNewItemsInFilter(); IXLPivotField SetIncludeNewItemsInFilter(Boolean value); IXLPivotField SetLayout(XLPivotLayout value); diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotField.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotField.cs index 749650b..84291fd 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotField.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotField.cs @@ -12,12 +12,13 @@ { SourceName = sourceName; SharedStrings = new List(); + Subtotals = new List(); } public String SourceName { get; private set; } public String CustomName { get; set; } public IXLPivotField SetCustomName(String value) { CustomName = value; return this; } - public XLSubtotalFunction Subtotals { get; set; } public IXLPivotField SetSubtotals(XLSubtotalFunction value) { Subtotals = value; return this; } + public List Subtotals { get; private set; } public IXLPivotField AddSubtotal(XLSubtotalFunction value) { Subtotals.Add(value); return this; } public Boolean IncludeNewItemsInFilter { get; set; } public IXLPivotField SetIncludeNewItemsInFilter() { IncludeNewItemsInFilter = true; return this; } public IXLPivotField SetIncludeNewItemsInFilter(Boolean value) { IncludeNewItemsInFilter = value; return this; } public XLPivotLayout Layout { get; set; } public IXLPivotField SetLayout(XLPivotLayout value) { Layout = value; return this; } diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotTable.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotTable.cs index 940c4b9..dc2b6ee 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotTable.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/PivotTables/XLPivotTable.cs @@ -104,6 +104,8 @@ RepeatRowLabels = true; SaveSourceData = true; EnableShowDetails = true; + ShowColumnHeaders = true; + ShowRowHeaders = true; } } diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs index e199bad..c14f9df 100644 --- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs +++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs @@ -3875,37 +3875,37 @@ // Generates content of pivotTablePart private static void GeneratePivotTablePartContent(PivotTablePart pivotTablePart1, IXLPivotTable pt) { - var pivotTableDefinition = new PivotTableDefinition() - { - Name = pt.Name, - CacheId = 0U, - DataCaption = "Values", // TODO: Don't hard code value - MergeItem = pt.MergeAndCenterWithLabels, - Indent = Convert.ToUInt32(pt.RowLabelIndent), - PageOverThenDown = (pt.FilterAreaOrder == XLFilterAreaOrder.OverThenDown), - PageWrap = Convert.ToUInt32(pt.FilterFieldsPageWrap), - ShowError = String.IsNullOrEmpty(pt.ErrorValueReplacement), - UseAutoFormatting = pt.AutofitColumns, - PreserveFormatting = pt.PreserveCellFormatting, - RowGrandTotals = pt.ShowGrandTotalsRows, - ColumnGrandTotals = pt.ShowGrandTotalsColumns, - SubtotalHiddenItems = pt.FilteredItemsInSubtotals, - MultipleFieldFilters = pt.AllowMultipleFilters, - CustomListSort = pt.UseCustomListsForSorting, - ShowDrill = pt.ShowExpandCollapseButtons, - ShowDataTips = pt.ShowContextualTooltips, - ShowMemberPropertyTips = pt.ShowPropertiesInTooltips, - ShowHeaders = pt.DisplayCaptionsAndDropdowns, - GridDropZones = pt.ClassicPivotTableLayout, - ShowEmptyRow = pt.ShowEmptyItemsOnRows, - ShowEmptyColumn = pt.ShowEmptyItemsOnColumns, - ShowItems = pt.DisplayItemLabels, - FieldListSortAscending = pt.SortFieldsAtoZ, - PrintDrill = pt.PrintExpandCollapsedButtons, - ItemPrintTitles = pt.RepeatRowLabels, - FieldPrintTitles = pt.PrintTitles, - EnableDrill = pt.EnableShowDetails - }; + var pivotTableDefinition = new PivotTableDefinition + { + Name = pt.Name, + CacheId = 0U, + DataCaption = "Values", + MergeItem = GetBooleanValue(pt.MergeAndCenterWithLabels, true), + Indent = Convert.ToUInt32(pt.RowLabelIndent), + PageOverThenDown = (pt.FilterAreaOrder == XLFilterAreaOrder.OverThenDown), + PageWrap = Convert.ToUInt32(pt.FilterFieldsPageWrap), + ShowError = String.IsNullOrEmpty(pt.ErrorValueReplacement), + UseAutoFormatting = GetBooleanValue(pt.AutofitColumns, true), + PreserveFormatting = GetBooleanValue(pt.PreserveCellFormatting, true), + RowGrandTotals = GetBooleanValue(pt.ShowGrandTotalsRows, true), + ColumnGrandTotals = GetBooleanValue(pt.ShowGrandTotalsColumns, true), + SubtotalHiddenItems = GetBooleanValue(pt.FilteredItemsInSubtotals, true), + MultipleFieldFilters = GetBooleanValue(pt.AllowMultipleFilters, true), + CustomListSort = GetBooleanValue(pt.UseCustomListsForSorting, true), + ShowDrill = GetBooleanValue(pt.ShowExpandCollapseButtons, true), + ShowDataTips = GetBooleanValue(pt.ShowContextualTooltips, true), + ShowMemberPropertyTips = GetBooleanValue(pt.ShowPropertiesInTooltips, true), + ShowHeaders = GetBooleanValue(pt.DisplayCaptionsAndDropdowns, true), + GridDropZones = GetBooleanValue(pt.ClassicPivotTableLayout, true), + ShowEmptyRow = GetBooleanValue(pt.ShowEmptyItemsOnRows, true), + ShowEmptyColumn = GetBooleanValue(pt.ShowEmptyItemsOnColumns, true), + ShowItems = GetBooleanValue(pt.DisplayItemLabels, true), + FieldListSortAscending = GetBooleanValue(pt.SortFieldsAtoZ, true), + PrintDrill = GetBooleanValue(pt.PrintExpandCollapsedButtons, true), + ItemPrintTitles = GetBooleanValue(pt.RepeatRowLabels, true), + FieldPrintTitles = GetBooleanValue(pt.PrintTitles, true), + EnableDrill = GetBooleanValue(pt.EnableShowDetails, true) + }; if (pt.EmptyCellReplacement != null) { @@ -4067,7 +4067,7 @@ } pivotTableDefinition.AppendChild(dataFields); - pivotTableDefinition.AppendChild(new PivotTableStyle { Name = Enum.GetName(typeof(XLTableTheme), pt.Theme), ShowRowHeaders = pt.ShowRowHeaders, ShowColumnHeaders = pt.ShowColumnHeaders, ShowRowStripes = pt.ShowRowStripes, ShowColumnStripes = pt.ShowColumnStripes }); + pivotTableDefinition.AppendChild(new PivotTableStyle { Name = Enum.GetName(typeof(XLPivotTableTheme), pt.Theme), ShowRowHeaders = pt.ShowRowHeaders, ShowColumnHeaders = pt.ShowColumnHeaders, ShowRowStripes = pt.ShowRowStripes, ShowColumnStripes = pt.ShowColumnStripes }); #region Excel 2010 Features