| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,297 @@ | ||
| package excelize | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestAddSparkline(t *testing.T) { | ||
| f := prepareSparklineDataset() | ||
|
|
||
| // Set the columns widths to make the output clearer | ||
| style, err := f.NewStyle(`{"font":{"bold":true}}`) | ||
| assert.NoError(t, err) | ||
| assert.NoError(t, f.SetCellStyle("Sheet1", "A1", "B1", style)) | ||
| assert.NoError(t, f.SetSheetViewOptions("Sheet1", 0, ZoomScale(150))) | ||
|
|
||
| f.SetColWidth("Sheet1", "A", "A", 14) | ||
| f.SetColWidth("Sheet1", "B", "B", 50) | ||
| // Headings | ||
| f.SetCellValue("Sheet1", "A1", "Sparkline") | ||
| f.SetCellValue("Sheet1", "B1", "Description") | ||
|
|
||
| f.SetCellValue("Sheet1", "B2", `A default "line" sparkline.`) | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A2"}, | ||
| Range: []string{"Sheet3!A1:J1"}, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B3", `A default "column" sparkline.`) | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A3"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B4", `A default "win/loss" sparkline.`) | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A4"}, | ||
| Range: []string{"Sheet3!A3:J3"}, | ||
| Type: "win_loss", | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B6", "Line with markers.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A6"}, | ||
| Range: []string{"Sheet3!A1:J1"}, | ||
| Markers: true, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B7", "Line with high and low points.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A7"}, | ||
| Range: []string{"Sheet3!A1:J1"}, | ||
| High: true, | ||
| Low: true, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B8", "Line with first and last point markers.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A8"}, | ||
| Range: []string{"Sheet3!A1:J1"}, | ||
| First: true, | ||
| Last: true, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B9", "Line with negative point markers.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A9"}, | ||
| Range: []string{"Sheet3!A1:J1"}, | ||
| Negative: true, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B10", "Line with axis.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A10"}, | ||
| Range: []string{"Sheet3!A1:J1"}, | ||
| Axis: true, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B12", "Column with default style (1).") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A12"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B13", "Column with style 2.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A13"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| Style: 2, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B14", "Column with style 3.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A14"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| Style: 3, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B15", "Column with style 4.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A15"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| Style: 4, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B16", "Column with style 5.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A16"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| Style: 5, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B17", "Column with style 6.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A17"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| Style: 6, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B18", "Column with a user defined color.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A18"}, | ||
| Range: []string{"Sheet3!A2:J2"}, | ||
| Type: "column", | ||
| SeriesColor: "#E965E0", | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B20", "A win/loss sparkline.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A20"}, | ||
| Range: []string{"Sheet3!A3:J3"}, | ||
| Type: "win_loss", | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B21", "A win/loss sparkline with negative points highlighted.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A21"}, | ||
| Range: []string{"Sheet3!A3:J3"}, | ||
| Type: "win_loss", | ||
| Negative: true, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B23", "A left to right column (the default).") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A23"}, | ||
| Range: []string{"Sheet3!A4:J4"}, | ||
| Type: "column", | ||
| Style: 20, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B24", "A right to left column.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A24"}, | ||
| Range: []string{"Sheet3!A4:J4"}, | ||
| Type: "column", | ||
| Style: 20, | ||
| Reverse: true, | ||
| })) | ||
|
|
||
| f.SetCellValue("Sheet1", "B25", "Sparkline and text in one cell.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A25"}, | ||
| Range: []string{"Sheet3!A4:J4"}, | ||
| Type: "column", | ||
| Style: 20, | ||
| })) | ||
| f.SetCellValue("Sheet1", "A25", "Growth") | ||
|
|
||
| f.SetCellValue("Sheet1", "B27", "A grouped sparkline. Changes are applied to all three.") | ||
| assert.NoError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A27", "A28", "A29"}, | ||
| Range: []string{"Sheet3!A5:J5", "Sheet3!A6:J6", "Sheet3!A7:J7"}, | ||
| Markers: true, | ||
| })) | ||
|
|
||
| // Sheet2 sections | ||
| assert.NoError(t, f.AddSparkline("Sheet2", &SparklineOption{ | ||
| Location: []string{"F3"}, | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| Type: "win_loss", | ||
| Negative: true, | ||
| })) | ||
|
|
||
| assert.NoError(t, f.AddSparkline("Sheet2", &SparklineOption{ | ||
| Location: []string{"F1"}, | ||
| Range: []string{"Sheet2!A1:E1"}, | ||
| Markers: true, | ||
| })) | ||
|
|
||
| assert.NoError(t, f.AddSparkline("Sheet2", &SparklineOption{ | ||
| Location: []string{"F2"}, | ||
| Range: []string{"Sheet2!A2:E2"}, | ||
| Type: "column", | ||
| Style: 12, | ||
| })) | ||
|
|
||
| assert.NoError(t, f.AddSparkline("Sheet2", &SparklineOption{ | ||
| Location: []string{"F3"}, | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| Type: "win_loss", | ||
| Negative: true, | ||
| })) | ||
|
|
||
| // Save xlsx file by the given path. | ||
| assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddSparkline.xlsx"))) | ||
|
|
||
| // Test error exceptions | ||
| assert.EqualError(t, f.AddSparkline("SheetN", &SparklineOption{ | ||
| Location: []string{"F3"}, | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| }), "sheet SheetN is not exist") | ||
|
|
||
| assert.EqualError(t, f.AddSparkline("Sheet1", nil), "parameter is required") | ||
|
|
||
| assert.EqualError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| }), `parameter 'Location' is required`) | ||
|
|
||
| assert.EqualError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"F3"}, | ||
| }), `parameter 'Range' is required`) | ||
|
|
||
| assert.EqualError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"F2", "F3"}, | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| }), `must have the same number of 'Location' and 'Range' parameters`) | ||
|
|
||
| assert.EqualError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"F3"}, | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| Type: "unknown_type", | ||
| }), `parameter 'Type' must be 'line', 'column' or 'win_loss'`) | ||
|
|
||
| assert.EqualError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"F3"}, | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| Style: -1, | ||
| }), `parameter 'Style' must betweent 0-35`) | ||
|
|
||
| assert.EqualError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"F3"}, | ||
| Range: []string{"Sheet2!A3:E3"}, | ||
| Style: -1, | ||
| }), `parameter 'Style' must betweent 0-35`) | ||
|
|
||
| f.Sheet["xl/worksheets/sheet1.xml"].ExtLst.Ext = `<extLst> | ||
| <ext x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main" uri="{05C60535-1F16-4fd2-B633-F4F36F0B64E0}"> | ||
| <x14:sparklineGroups | ||
| xmlns:xm="http://schemas.microsoft.com/office/excel/2006/main"> | ||
| <x14:sparklineGroup> | ||
| </x14:sparklines> | ||
| </x14:sparklineGroup> | ||
| </x14:sparklineGroups> | ||
| </ext> | ||
| </extLst>` | ||
| assert.EqualError(t, f.AddSparkline("Sheet1", &SparklineOption{ | ||
| Location: []string{"A2"}, | ||
| Range: []string{"Sheet3!A1:J1"}, | ||
| }), "XML syntax error on line 6: element <sparklineGroup> closed by </sparklines>") | ||
| } | ||
|
|
||
| func prepareSparklineDataset() *File { | ||
| f := NewFile() | ||
| sheet2 := [][]int{ | ||
| {-2, 2, 3, -1, 0}, | ||
| {30, 20, 33, 20, 15}, | ||
| {1, -1, -1, 1, -1}, | ||
| } | ||
| sheet3 := [][]int{ | ||
| {-2, 2, 3, -1, 0, -2, 3, 2, 1, 0}, | ||
| {30, 20, 33, 20, 15, 5, 5, 15, 10, 15}, | ||
| {1, 1, -1, -1, 1, -1, 1, 1, 1, -1}, | ||
| {5, 6, 7, 10, 15, 20, 30, 50, 70, 100}, | ||
| {-2, 2, 3, -1, 0, -2, 3, 2, 1, 0}, | ||
| {3, -1, 0, -2, 3, 2, 1, 0, 2, 1}, | ||
| {0, -2, 3, 2, 1, 0, 1, 2, 3, 1}, | ||
| } | ||
| f.NewSheet("Sheet2") | ||
| f.NewSheet("Sheet3") | ||
| for row, data := range sheet2 { | ||
| f.SetSheetRow("Sheet2", fmt.Sprintf("A%d", row+1), &data) | ||
| } | ||
| for row, data := range sheet3 { | ||
| f.SetSheetRow("Sheet3", fmt.Sprintf("A%d", row+1), &data) | ||
| } | ||
| return f | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of | ||
| // this source code is governed by a BSD-style license that can be found in | ||
| // the LICENSE file. | ||
| // | ||
| // Package excelize providing a set of functions that allow you to write to | ||
| // and read from XLSX files. Support reads and writes XLSX file generated by | ||
| // Microsoft Excel™ 2007 and later. Support save file without losing original | ||
| // charts of XLSX. This library needs Go version 1.10 or later. | ||
|
|
||
| package excelize | ||
|
|
||
| import "encoding/xml" | ||
|
|
||
| // xlsxProperties specifies to an OOXML document properties such as the | ||
| // template used, the number of pages and words, and the application name and | ||
| // version. | ||
| type xlsxProperties struct { | ||
| XMLName xml.Name `xml:"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties Properties"` | ||
| Template string | ||
| Manager string | ||
| Company string | ||
| Pages int | ||
| Words int | ||
| Characters int | ||
| PresentationFormat string | ||
| Lines int | ||
| Paragraphs int | ||
| Slides int | ||
| Notes int | ||
| TotalTime int | ||
| HiddenSlides int | ||
| MMClips int | ||
| ScaleCrop bool | ||
| HeadingPairs *xlsxVectorVariant | ||
| TitlesOfParts *xlsxVectorLpstr | ||
| LinksUpToDate bool | ||
| CharactersWithSpaces int | ||
| SharedDoc bool | ||
| HyperlinkBase string | ||
| HLinks *xlsxVectorVariant | ||
| HyperlinksChanged bool | ||
| DigSig *xlsxDigSig | ||
| Application string | ||
| AppVersion string | ||
| DocSecurity int | ||
| } | ||
|
|
||
| // xlsxVectorVariant specifies the set of hyperlinks that were in this | ||
| // document when last saved. | ||
| type xlsxVectorVariant struct { | ||
| Content string `xml:",innerxml"` | ||
| } | ||
|
|
||
| type xlsxVectorLpstr struct { | ||
| Content string `xml:",innerxml"` | ||
| } | ||
|
|
||
| // xlsxDigSig contains the signature of a digitally signed document. | ||
| type xlsxDigSig struct { | ||
| Content string `xml:",innerxml"` | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Copyright 2016 - 2019 The excelize Authors. All rights reserved. Use of | ||
| // this source code is governed by a BSD-style license that can be found in | ||
| // the LICENSE file. | ||
| // | ||
| // Package excelize providing a set of functions that allow you to write to | ||
| // and read from XLSX files. Support reads and writes XLSX file generated by | ||
| // Microsoft Excel™ 2007 and later. Support save file without losing original | ||
| // charts of XLSX. This library needs Go version 1.10 or later. | ||
|
|
||
| package excelize | ||
|
|
||
| import "encoding/xml" | ||
|
|
||
| // DocProperties directly maps the document core properties. | ||
| type DocProperties struct { | ||
| Category string | ||
| ContentStatus string | ||
| Created string | ||
| Creator string | ||
| Description string | ||
| Identifier string | ||
| Keywords string | ||
| LastModifiedBy string | ||
| Modified string | ||
| Revision string | ||
| Subject string | ||
| Title string | ||
| Language string | ||
| Version string | ||
| } | ||
|
|
||
| // decodeCoreProperties directly maps the root element for a part of this | ||
| // content type shall coreProperties. In order to solve the problem that the | ||
| // label structure is changed after serialization and deserialization, two | ||
| // different structures are defined. decodeCoreProperties just for | ||
| // deserialization. | ||
| type decodeCoreProperties struct { | ||
| XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties coreProperties"` | ||
| Title string `xml:"http://purl.org/dc/elements/1.1/ title,omitempty"` | ||
| Subject string `xml:"http://purl.org/dc/elements/1.1/ subject,omitempty"` | ||
| Creator string `xml:"http://purl.org/dc/elements/1.1/ creator"` | ||
| Keywords string `xml:"keywords,omitempty"` | ||
| Description string `xml:"http://purl.org/dc/elements/1.1/ description,omitempty"` | ||
| LastModifiedBy string `xml:"lastModifiedBy"` | ||
| Language string `xml:"http://purl.org/dc/elements/1.1/ language,omitempty"` | ||
| Identifier string `xml:"http://purl.org/dc/elements/1.1/ identifier,omitempty"` | ||
| Revision string `xml:"revision,omitempty"` | ||
| Created struct { | ||
| Text string `xml:",chardata"` | ||
| Type string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"` | ||
| } `xml:"http://purl.org/dc/terms/ created"` | ||
| Modified struct { | ||
| Text string `xml:",chardata"` | ||
| Type string `xml:"http://www.w3.org/2001/XMLSchema-instance type,attr"` | ||
| } `xml:"http://purl.org/dc/terms/ modified"` | ||
| ContentStatus string `xml:"contentStatus,omitempty"` | ||
| Category string `xml:"category,omitempty"` | ||
| Version string `xml:"version,omitempty"` | ||
| } | ||
|
|
||
| // xlsxCoreProperties directly maps the root element for a part of this | ||
| // content type shall coreProperties. | ||
| type xlsxCoreProperties struct { | ||
| XMLName xml.Name `xml:"http://schemas.openxmlformats.org/package/2006/metadata/core-properties coreProperties"` | ||
| Dc string `xml:"xmlns:dc,attr"` | ||
| Dcterms string `xml:"xmlns:dcterms,attr"` | ||
| Dcmitype string `xml:"xmlns:dcmitype,attr"` | ||
| XSI string `xml:"xmlns:xsi,attr"` | ||
| Title string `xml:"dc:title,omitempty"` | ||
| Subject string `xml:"dc:subject,omitempty"` | ||
| Creator string `xml:"dc:creator"` | ||
| Keywords string `xml:"keywords,omitempty"` | ||
| Description string `xml:"dc:description,omitempty"` | ||
| LastModifiedBy string `xml:"lastModifiedBy"` | ||
| Language string `xml:"dc:language,omitempty"` | ||
| Identifier string `xml:"dc:identifier,omitempty"` | ||
| Revision string `xml:"revision,omitempty"` | ||
| Created struct { | ||
| Text string `xml:",chardata"` | ||
| Type string `xml:"xsi:type,attr"` | ||
| } `xml:"dcterms:created"` | ||
| Modified struct { | ||
| Text string `xml:",chardata"` | ||
| Type string `xml:"xsi:type,attr"` | ||
| } `xml:"dcterms:modified"` | ||
| ContentStatus string `xml:"contentStatus,omitempty"` | ||
| Category string `xml:"category,omitempty"` | ||
| Version string `xml:"version,omitempty"` | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,218 @@ | ||
| package excelize | ||
|
|
||
| import "encoding/xml" | ||
|
|
||
| // xlsxPivotCacheDefinition represents the pivotCacheDefinition part. This part | ||
| // defines each field in the source data, including the name, the string | ||
| // resources of the instance data (for shared items), and information about | ||
| // the type of data that appears in the field. | ||
| type xlsxPivotCacheDefinition struct { | ||
| XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main pivotCacheDefinition"` | ||
| RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` | ||
| Invalid bool `xml:"invalid,attr,omitempty"` | ||
| SaveData bool `xml:"saveData,attr"` | ||
| RefreshOnLoad bool `xml:"refreshOnLoad,attr,omitempty"` | ||
| OptimizeMemory bool `xml:"optimizeMemory,attr,omitempty"` | ||
| EnableRefresh bool `xml:"enableRefresh,attr,omitempty"` | ||
| RefreshedBy string `xml:"refreshedBy,attr,omitempty"` | ||
| RefreshedDate float64 `xml:"refreshedDate,attr,omitempty"` | ||
| RefreshedDateIso float64 `xml:"refreshedDateIso,attr,omitempty"` | ||
| BackgroundQuery bool `xml:"backgroundQuery,attr"` | ||
| MissingItemsLimit int `xml:"missingItemsLimit,attr,omitempty"` | ||
| CreatedVersion int `xml:"createdVersion,attr,omitempty"` | ||
| RefreshedVersion int `xml:"refreshedVersion,attr,omitempty"` | ||
| MinRefreshableVersion int `xml:"minRefreshableVersion,attr,omitempty"` | ||
| RecordCount int `xml:"recordCount,attr,omitempty"` | ||
| UpgradeOnRefresh bool `xml:"upgradeOnRefresh,attr,omitempty"` | ||
| TupleCacheAttr bool `xml:"tupleCache,attr,omitempty"` | ||
| SupportSubquery bool `xml:"supportSubquery,attr,omitempty"` | ||
| SupportAdvancedDrill bool `xml:"supportAdvancedDrill,attr,omitempty"` | ||
| CacheSource *xlsxCacheSource `xml:"cacheSource"` | ||
| CacheFields *xlsxCacheFields `xml:"cacheFields"` | ||
| CacheHierarchies *xlsxCacheHierarchies `xml:"cacheHierarchies"` | ||
| Kpis *xlsxKpis `xml:"kpis"` | ||
| TupleCache *xlsxTupleCache `xml:"tupleCache"` | ||
| CalculatedItems *xlsxCalculatedItems `xml:"calculatedItems"` | ||
| CalculatedMembers *xlsxCalculatedMembers `xml:"calculatedMembers"` | ||
| Dimensions *xlsxDimensions `xml:"dimensions"` | ||
| MeasureGroups *xlsxMeasureGroups `xml:"measureGroups"` | ||
| Maps *xlsxMaps `xml:"maps"` | ||
| ExtLst *xlsxExtLst `xml:"extLst"` | ||
| } | ||
|
|
||
| // xlsxCacheSource represents the description of data source whose data is | ||
| // stored in the pivot cache. The data source refers to the underlying rows or | ||
| // database records that provide the data for a PivotTable. You can create a | ||
| // PivotTable report from a SpreadsheetML table, an external database | ||
| // (including OLAP cubes), multiple SpreadsheetML worksheets, or another | ||
| // PivotTable. | ||
| type xlsxCacheSource struct { | ||
| Type string `xml:"type,attr"` | ||
| ConnectionId int `xml:"connectionId,attr,omitempty"` | ||
| WorksheetSource *xlsxWorksheetSource `xml:"worksheetSource"` | ||
| Consolidation *xlsxConsolidation `xml:"consolidation"` | ||
| ExtLst *xlsxExtLst `xml:"extLst"` | ||
| } | ||
|
|
||
| // xlsxWorksheetSource represents the location of the source of the data that | ||
| // is stored in the cache. | ||
| type xlsxWorksheetSource struct { | ||
| RID string `xml:"http://schemas.openxmlformats.org/officeDocument/2006/relationships id,attr,omitempty"` | ||
| Ref string `xml:"ref,attr,omitempty"` | ||
| Name string `xml:"name,attr,omitempty"` | ||
| Sheet string `xml:"sheet,attr,omitempty"` | ||
| } | ||
|
|
||
| // xlsxConsolidation represents the description of the PivotCache source using | ||
| // multiple consolidation ranges. This element is used when the source of the | ||
| // PivotTable is a collection of ranges in the workbook. The ranges are | ||
| // specified in the rangeSets collection. The logic for how the application | ||
| // consolidates the data in the ranges is application- defined. | ||
| type xlsxConsolidation struct { | ||
| } | ||
|
|
||
| // xlsxCacheFields represents the collection of field definitions in the | ||
| // source data. | ||
| type xlsxCacheFields struct { | ||
| Count int `xml:"count,attr"` | ||
| CacheField []*xlsxCacheField `xml:"cacheField"` | ||
| } | ||
|
|
||
| // xlsxCacheField represent a single field in the PivotCache. This definition | ||
| // contains information about the field, such as its source, data type, and | ||
| // location within a level or hierarchy. The sharedItems element stores | ||
| // additional information about the data in this field. If there are no shared | ||
| // items, then values are stored directly in the pivotCacheRecords part. | ||
| type xlsxCacheField struct { | ||
| Name string `xml:"name,attr"` | ||
| Caption string `xml:"caption,attr,omitempty"` | ||
| PropertyName string `xml:"propertyName,attr,omitempty"` | ||
| ServerField bool `xml:"serverField,attr,omitempty"` | ||
| UniqueList bool `xml:"uniqueList,attr,omitempty"` | ||
| NumFmtId int `xml:"numFmtId,attr"` | ||
| Formula string `xml:"formula,attr,omitempty"` | ||
| SQLType int `xml:"sqlType,attr,omitempty"` | ||
| Hierarchy int `xml:"hierarchy,attr,omitempty"` | ||
| Level int `xml:"level,attr,omitempty"` | ||
| DatabaseField bool `xml:"databaseField,attr,omitempty"` | ||
| MappingCount int `xml:"mappingCount,attr,omitempty"` | ||
| MemberPropertyField bool `xml:"memberPropertyField,attr,omitempty"` | ||
| SharedItems *xlsxSharedItems `xml:"sharedItems"` | ||
| FieldGroup *xlsxFieldGroup `xml:"fieldGroup"` | ||
| MpMap *xlsxX `xml:"mpMap"` | ||
| ExtLst *xlsxExtLst `xml:"extLst"` | ||
| } | ||
|
|
||
| // xlsxSharedItems represents the collection of unique items for a field in | ||
| // the PivotCacheDefinition. The sharedItems complex type stores data type and | ||
| // formatting information about the data in a field. Items in the | ||
| // PivotCacheDefinition can be shared in order to reduce the redundancy of | ||
| // those values that are referenced in multiple places across all the | ||
| // PivotTable parts. | ||
| type xlsxSharedItems struct { | ||
| ContainsSemiMixedTypes bool `xml:"containsSemiMixedTypes,attr,omitempty"` | ||
| ContainsNonDate bool `xml:"containsNonDate,attr,omitempty"` | ||
| ContainsDate bool `xml:"containsDate,attr,omitempty"` | ||
| ContainsString bool `xml:"containsString,attr,omitempty"` | ||
| ContainsBlank bool `xml:"containsBlank,attr,omitempty"` | ||
| ContainsMixedTypes bool `xml:"containsMixedTypes,attr,omitempty"` | ||
| ContainsNumber bool `xml:"containsNumber,attr,omitempty"` | ||
| ContainsInteger bool `xml:"containsInteger,attr,omitempty"` | ||
| MinValue float64 `xml:"minValue,attr,omitempty"` | ||
| MaxValue float64 `xml:"maxValue,attr,omitempty"` | ||
| MinDate string `xml:"minDate,attr,omitempty"` | ||
| MaxDate string `xml:"maxDate,attr,omitempty"` | ||
| Count int `xml:"count,attr"` | ||
| LongText bool `xml:"longText,attr,omitempty"` | ||
| M *xlsxMissing `xml:"m"` | ||
| N *xlsxNumber `xml:"n"` | ||
| B *xlsxBoolean `xml:"b"` | ||
| E *xlsxError `xml:"e"` | ||
| S *xlsxString `xml:"s"` | ||
| D *xlsxDateTime `xml:"d"` | ||
| } | ||
|
|
||
| // xlsxMissing represents a value that was not specified. | ||
| type xlsxMissing struct { | ||
| } | ||
|
|
||
| // xlsxNumber represents a numeric value in the PivotTable. | ||
| type xlsxNumber struct { | ||
| V float64 `xml:"v,attr"` | ||
| U bool `xml:"u,attr,omitempty"` | ||
| F bool `xml:"f,attr,omitempty"` | ||
| C string `xml:"c,attr,omitempty"` | ||
| Cp int `xml:"cp,attr,omitempty"` | ||
| In int `xml:"in,attr,omitempty"` | ||
| Bc string `xml:"bc,attr,omitempty"` | ||
| Fc string `xml:"fc,attr,omitempty"` | ||
| I bool `xml:"i,attr,omitempty"` | ||
| Un bool `xml:"un,attr,omitempty"` | ||
| St bool `xml:"st,attr,omitempty"` | ||
| B bool `xml:"b,attr,omitempty"` | ||
| Tpls *xlsxTuples `xml:"tpls"` | ||
| X *attrValInt `xml:"x"` | ||
| } | ||
|
|
||
| // xlsxTuples represents members for the OLAP sheet data entry, also known as | ||
| // a tuple. | ||
| type xlsxTuples struct { | ||
| } | ||
|
|
||
| // xlsxBoolean represents a boolean value for an item in the PivotTable. | ||
| type xlsxBoolean struct { | ||
| } | ||
|
|
||
| // xlsxError represents an error value. The use of this item indicates that an | ||
| // error value is present in the PivotTable source. The error is recorded in | ||
| // the value attribute. | ||
| type xlsxError struct { | ||
| } | ||
|
|
||
| // xlsxString represents a character value in a PivotTable. | ||
| type xlsxString struct { | ||
| } | ||
|
|
||
| // xlsxDateTime represents a date-time value in the PivotTable. | ||
| type xlsxDateTime struct { | ||
| } | ||
|
|
||
| // xlsxFieldGroup represents the collection of properties for a field group. | ||
| type xlsxFieldGroup struct { | ||
| } | ||
|
|
||
| // xlsxCacheHierarchies represents the collection of OLAP hierarchies in the | ||
| // PivotCache. | ||
| type xlsxCacheHierarchies struct { | ||
| } | ||
|
|
||
| // xlsxKpis represents the collection of Key Performance Indicators (KPIs) | ||
| // defined on the OLAP server and stored in the PivotCache. | ||
| type xlsxKpis struct { | ||
| } | ||
|
|
||
| // xlsxTupleCache represents the cache of OLAP sheet data members, or tuples. | ||
| type xlsxTupleCache struct { | ||
| } | ||
|
|
||
| // xlsxCalculatedItems represents the collection of calculated items. | ||
| type xlsxCalculatedItems struct { | ||
| } | ||
|
|
||
| // xlsxCalculatedMembers represents the collection of calculated members in an | ||
| // OLAP PivotTable. | ||
| type xlsxCalculatedMembers struct { | ||
| } | ||
|
|
||
| // xlsxDimensions represents the collection of PivotTable OLAP dimensions. | ||
| type xlsxDimensions struct { | ||
| } | ||
|
|
||
| // xlsxMeasureGroups represents the collection of PivotTable OLAP measure | ||
| // groups. | ||
| type xlsxMeasureGroups struct { | ||
| } | ||
|
|
||
| // xlsxMaps represents the PivotTable OLAP measure group - Dimension maps. | ||
| type xlsxMaps struct { | ||
| } |