diff --git a/go.mod b/go.mod index 6e31bbc9c0..c9192e52d9 100644 --- a/go.mod +++ b/go.mod @@ -8,10 +8,10 @@ require ( github.com/stretchr/testify v1.8.4 github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 - golang.org/x/crypto v0.25.0 + golang.org/x/crypto v0.26.0 golang.org/x/image v0.18.0 - golang.org/x/net v0.27.0 - golang.org/x/text v0.16.0 + golang.org/x/net v0.28.0 + golang.org/x/text v0.17.0 ) require ( diff --git a/go.sum b/go.sum index 904edc85c8..346cd7758d 100644 --- a/go.sum +++ b/go.sum @@ -15,14 +15,14 @@ github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7 github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI= github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 h1:hPVCafDV85blFTabnqKgNhDCkJX25eik94Si9cTER4A= github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ= golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/pivotTable.go b/pivotTable.go index 6205c54311..9caf037872 100644 --- a/pivotTable.go +++ b/pivotTable.go @@ -58,6 +58,8 @@ type PivotTableOptions struct { ShowRowStripes bool ShowColStripes bool ShowLastColumn bool + FieldPrintTitles bool + ItemPrintTitles bool PivotTableStyleName string } @@ -90,6 +92,8 @@ type PivotTableField struct { Data string Name string Outline bool + ShowAll bool + InsertBlankRow bool Subtotal string DefaultSubtotal bool NumFmt int @@ -349,6 +353,8 @@ func (f *File) addPivotTable(cacheID, pivotTableID int, opts *PivotTableOptions) CreatedVersion: pivotTableVersion, CompactData: &opts.CompactData, ShowError: &opts.ShowError, + FieldPrintTitles: opts.FieldPrintTitles, + ItemPrintTitles: opts.ItemPrintTitles, DataCaption: "Values", Location: &xlsxLocation{ Ref: topLeftCell + ":" + bottomRightCell, @@ -555,6 +561,8 @@ func (f *File) addPivotFields(pt *xlsxPivotTableDefinition, opts *PivotTableOpti DataField: inPivotTableField(opts.Data, name) != -1, Compact: &rowOptions.Compact, Outline: &rowOptions.Outline, + ShowAll: rowOptions.ShowAll, + InsertBlankRow: rowOptions.InsertBlankRow, DefaultSubtotal: &rowOptions.DefaultSubtotal, Items: &xlsxItems{ Count: len(items), @@ -591,6 +599,8 @@ func (f *File) addPivotFields(pt *xlsxPivotTableDefinition, opts *PivotTableOpti DataField: inPivotTableField(opts.Data, name) != -1, Compact: &columnOptions.Compact, Outline: &columnOptions.Outline, + ShowAll: columnOptions.ShowAll, + InsertBlankRow: columnOptions.InsertBlankRow, DefaultSubtotal: &columnOptions.DefaultSubtotal, Items: &xlsxItems{ Count: len(items), @@ -831,12 +841,14 @@ func (f *File) getPivotTable(sheet, pivotTableXML, pivotCacheRels string) (Pivot return opts, err } opts = PivotTableOptions{ - pivotTableXML: pivotTableXML, - pivotCacheXML: pivotCacheXML, - pivotSheetName: sheet, - DataRange: fmt.Sprintf("%s!%s", pc.CacheSource.WorksheetSource.Sheet, pc.CacheSource.WorksheetSource.Ref), - PivotTableRange: fmt.Sprintf("%s!%s", sheet, pt.Location.Ref), - Name: pt.Name, + pivotTableXML: pivotTableXML, + pivotCacheXML: pivotCacheXML, + pivotSheetName: sheet, + DataRange: fmt.Sprintf("%s!%s", pc.CacheSource.WorksheetSource.Sheet, pc.CacheSource.WorksheetSource.Ref), + PivotTableRange: fmt.Sprintf("%s!%s", sheet, pt.Location.Ref), + Name: pt.Name, + FieldPrintTitles: pt.FieldPrintTitles, + ItemPrintTitles: pt.ItemPrintTitles, } if pc.CacheSource.WorksheetSource.Name != "" { opts.DataRange = pc.CacheSource.WorksheetSource.Name @@ -924,7 +936,9 @@ func (f *File) extractPivotTableFields(order []string, pt *xlsxPivotTableDefinit // settings by given pivot table fields. func extractPivotTableField(data string, fld *xlsxPivotField) PivotTableField { pivotTableField := PivotTableField{ - Data: data, + Data: data, + ShowAll: fld.ShowAll, + InsertBlankRow: fld.InsertBlankRow, } fields := []string{"Compact", "Name", "Outline", "Subtotal", "DefaultSubtotal"} immutable, mutable := reflect.ValueOf(*fld), reflect.ValueOf(&pivotTableField).Elem() diff --git a/pivotTable_test.go b/pivotTable_test.go index 50f95bfc43..74ce61bec0 100644 --- a/pivotTable_test.go +++ b/pivotTable_test.go @@ -31,9 +31,9 @@ func TestPivotTable(t *testing.T) { DataRange: "Sheet1!A1:E31", PivotTableRange: "Sheet1!G2:M34", Name: "PivotTable1", - Rows: []PivotTableField{{Data: "Month", DefaultSubtotal: true}, {Data: "Year"}}, + Rows: []PivotTableField{{Data: "Month", ShowAll: true, DefaultSubtotal: true}, {Data: "Year"}}, Filter: []PivotTableField{{Data: "Region"}}, - Columns: []PivotTableField{{Data: "Type", DefaultSubtotal: true}}, + Columns: []PivotTableField{{Data: "Type", ShowAll: true, InsertBlankRow: true, DefaultSubtotal: true}}, Data: []PivotTableField{{Data: "Sales", Subtotal: "Sum", Name: "Summarize by Sum", NumFmt: 38}}, RowGrandTotals: true, ColGrandTotals: true, @@ -42,6 +42,8 @@ func TestPivotTable(t *testing.T) { ShowColHeaders: true, ShowLastColumn: true, ShowError: true, + ItemPrintTitles: true, + FieldPrintTitles: true, PivotTableStyleName: "PivotStyleLight16", } assert.NoError(t, f.AddPivotTable(expected)) diff --git a/templates.go b/templates.go index 3bf4c5fe69..5aafc43e8a 100644 --- a/templates.go +++ b/templates.go @@ -102,6 +102,7 @@ const ( ExtURICalcFeatures = "{B58B0392-4F1F-4190-BB64-5DF3571DCE5F}" ExtURIConditionalFormattingRuleID = "{B025F937-C7B1-47D3-B67F-A62EFF666E3E}" ExtURIConditionalFormattings = "{78C0D931-6437-407d-A8EE-F0AAD7539E65}" + ExtURIDataField = "{E15A36E0-9728-4E99-A89B-3F7291B0FE68}" ExtURIDataModel = "{FCE2AD5D-F65C-4FA6-A056-5C36A1767C68}" ExtURIDataValidations = "{CCE6A557-97BC-4b89-ADB6-D9C93CAAB3DF}" ExtURIDrawingBlip = "{28A0092B-C50C-407E-A947-70E740481C1C}" @@ -112,6 +113,9 @@ const ( ExtURIPivotCacheDefinition = "{725AE2AE-9491-48be-B2B4-4EB974FC3084}" ExtURIPivotCachesX14 = "{876F7934-8845-4945-9796-88D515C7AA90}" ExtURIPivotCachesX15 = "{841E416B-1EF1-43b6-AB56-02D37102CBD5}" + ExtURIPivotField = "{2946ED86-A175-432a-8AC1-64E0C546D7DE}" + ExtURIPivotFilter = "{0605FD5F-26C8-4aeb-8148-2DB25E43C511}" + ExtURIPivotHierarchy = "{F1805F06-0CD304483-9156-8803C3D141DF}" ExtURIPivotTableReferences = "{983426D0-5260-488c-9760-48F4B6AC55F4}" ExtURIProtectedRanges = "{FC87AEE6-9EDD-4A0A-B7FB-166176984837}" ExtURISlicerCacheDefinition = "{2F2917AC-EB37-4324-AD4E-5DD8C200BD13}"