2018-05-06 09:03:03 +08:00
package excelize
import (
"bytes"
"encoding/xml"
2020-01-14 00:33:36 +08:00
"fmt"
2019-06-09 09:53:02 +08:00
"path/filepath"
2018-05-06 09:03:03 +08:00
"testing"
2018-12-27 18:51:44 +08:00
"github.com/stretchr/testify/assert"
2018-05-06 09:03:03 +08:00
)
func TestChartSize ( t * testing . T ) {
2020-11-10 23:48:09 +08:00
f := NewFile ( )
sheet1 := f . GetSheetName ( 0 )
2018-05-06 09:03:03 +08:00
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
categories := map [ string ] string {
"A2" : "Small" ,
"A3" : "Normal" ,
"A4" : "Large" ,
"B1" : "Apple" ,
"C1" : "Orange" ,
"D1" : "Pear" ,
}
for cell , v := range categories {
2020-11-10 23:48:09 +08:00
assert . NoError ( t , f . SetCellValue ( sheet1 , cell , v ) )
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
}
2018-05-06 09:03:03 +08:00
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
values := map [ string ] int {
"B2" : 2 ,
"C2" : 3 ,
"D2" : 3 ,
"B3" : 5 ,
"C3" : 2 ,
"D3" : 4 ,
"B4" : 6 ,
"C4" : 7 ,
"D4" : 8 ,
2018-05-06 09:03:03 +08:00
}
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
for cell , v := range values {
2020-11-10 23:48:09 +08:00
assert . NoError ( t , f . SetCellValue ( sheet1 , cell , v ) )
2018-05-06 09:03:03 +08:00
}
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
assert . NoError ( t , f . AddChart ( "Sheet1" , "E4" , & Chart {
2023-04-01 00:08:53 +08:00
Type : Col3DClustered ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
Dimension : ChartDimension {
2023-01-02 11:47:31 +08:00
Width : 640 ,
Height : 480 ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
} ,
Series : [ ] ChartSeries {
{ Name : "Sheet1!$A$2" , Categories : "Sheet1!$B$1:$D$1" , Values : "Sheet1!$B$2:$D$2" } ,
{ Name : "Sheet1!$A$3" , Categories : "Sheet1!$B$1:$D$1" , Values : "Sheet1!$B$3:$D$3" } ,
{ Name : "Sheet1!$A$4" , Categories : "Sheet1!$B$1:$D$1" , Values : "Sheet1!$B$4:$D$4" } ,
} ,
Title : ChartTitle { Name : "3D Clustered Column Chart" } ,
} ) )
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
2019-12-24 01:09:28 +08:00
var buffer bytes . Buffer
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
2020-11-10 23:48:09 +08:00
// Save spreadsheet by the given path.
assert . NoError ( t , f . Write ( & buffer ) )
2018-05-06 09:03:03 +08:00
newFile , err := OpenReader ( & buffer )
2019-12-24 01:09:28 +08:00
assert . NoError ( t , err )
2018-05-06 09:03:03 +08:00
chartsNum := newFile . countCharts ( )
2018-12-27 18:51:44 +08:00
if ! assert . Equal ( t , 1 , chartsNum , "Expected 1 chart, actual %d" , chartsNum ) {
t . FailNow ( )
2018-05-06 09:03:03 +08:00
}
var (
workdir decodeWsDr
anchor decodeTwoCellAnchor
)
2021-07-05 00:03:56 +08:00
content , ok := newFile . Pkg . Load ( "xl/drawings/drawing1.xml" )
2018-12-27 18:51:44 +08:00
assert . True ( t , ok , "Can't open the chart" )
2018-05-06 09:03:03 +08:00
2021-07-05 00:03:56 +08:00
err = xml . Unmarshal ( content . ( [ ] byte ) , & workdir )
2018-12-27 18:51:44 +08:00
if ! assert . NoError ( t , err ) {
t . FailNow ( )
2018-05-06 09:03:03 +08:00
}
Huge refactorig for consistent col/row numbering (#356)
* Huge refactorig for consistent col/row numbering
Started from simply changing ToALphaString()/TitleToNumber() logic and related fixes.
But have to go deeper, do fixes, after do related fixes and again and again.
Major improvements:
1. Tests made stronger again (But still be weak).
2. "Empty" returns for incorrect input replaces with panic.
3. Check for correct col/row/cell naming & addressing by default.
4. Removed huge amount of duplicated code.
5. Removed ToALphaString(), TitleToNumber() and it helpers functions at all,
and replaced with SplitCellName(), JoinCellName(), ColumnNameToNumber(), ColumnNumberToName(), CellNameToCoordinates(), CoordinatesToCellName().
6. Minor fixes for internal variable naming for code readability (ex. col, row for input params, colIdx, rowIdx for slice indexes etc).
* Formatting fixes
2019-03-20 00:14:41 +08:00
err = xml . Unmarshal ( [ ] byte ( "<decodeTwoCellAnchor>" +
workdir . TwoCellAnchor [ 0 ] . Content + "</decodeTwoCellAnchor>" ) , & anchor )
2018-12-27 18:51:44 +08:00
if ! assert . NoError ( t , err ) {
t . FailNow ( )
2018-05-06 09:03:03 +08:00
}
2018-12-27 18:51:44 +08:00
if ! assert . Equal ( t , 4 , anchor . From . Col , "Expected 'from' column 4" ) ||
! assert . Equal ( t , 3 , anchor . From . Row , "Expected 'from' row 3" ) {
t . FailNow ( )
2018-05-06 09:03:03 +08:00
}
2018-12-27 18:51:44 +08:00
if ! assert . Equal ( t , 14 , anchor . To . Col , "Expected 'to' column 14" ) ||
! assert . Equal ( t , 27 , anchor . To . Row , "Expected 'to' row 27" ) {
t . FailNow ( )
}
2018-05-06 09:03:03 +08:00
}
2019-04-16 10:57:21 +08:00
func TestAddDrawingChart ( t * testing . T ) {
f := NewFile ( )
2021-12-07 00:26:53 +08:00
assert . EqualError ( t , f . addDrawingChart ( "SheetN" , "" , "" , 0 , 0 , 0 , nil ) , newCellNameToCoordinatesError ( "" , newInvalidCellNameError ( "" ) ) . Error ( ) )
2022-11-12 00:02:11 +08:00
path := "xl/drawings/drawing1.xml"
f . Pkg . Store ( path , MacintoshCyrillicCharset )
2023-01-02 11:47:31 +08:00
assert . EqualError ( t , f . addDrawingChart ( "Sheet1" , path , "A1" , 0 , 0 , 0 , & GraphicOptions { PrintObject : boolPtr ( true ) , Locked : boolPtr ( false ) } ) , "XML syntax error on line 1: invalid UTF-8" )
2022-11-12 00:02:11 +08:00
}
func TestAddSheetDrawingChart ( t * testing . T ) {
f := NewFile ( )
path := "xl/drawings/drawing1.xml"
f . Pkg . Store ( path , MacintoshCyrillicCharset )
2023-01-02 11:47:31 +08:00
assert . EqualError ( t , f . addSheetDrawingChart ( path , 0 , & GraphicOptions { PrintObject : boolPtr ( true ) , Locked : boolPtr ( false ) } ) , "XML syntax error on line 1: invalid UTF-8" )
2022-11-12 00:02:11 +08:00
}
func TestDeleteDrawing ( t * testing . T ) {
f := NewFile ( )
path := "xl/drawings/drawing1.xml"
f . Pkg . Store ( path , MacintoshCyrillicCharset )
assert . EqualError ( t , f . deleteDrawing ( 0 , 0 , path , "Chart" ) , "XML syntax error on line 1: invalid UTF-8" )
2019-04-16 10:57:21 +08:00
}
2019-06-09 09:53:02 +08:00
func TestAddChart ( t * testing . T ) {
f , err := OpenFile ( filepath . Join ( "test" , "Book1.xlsx" ) )
if ! assert . NoError ( t , err ) {
t . FailNow ( )
}
categories := map [ string ] string { "A30" : "SS" , "A31" : "S" , "A32" : "M" , "A33" : "L" , "A34" : "LL" , "A35" : "XL" , "A36" : "XXL" , "A37" : "XXXL" , "B29" : "Apple" , "C29" : "Orange" , "D29" : "Pear" }
values := map [ string ] int { "B30" : 1 , "C30" : 1 , "D30" : 1 , "B31" : 2 , "C31" : 2 , "D31" : 2 , "B32" : 3 , "C32" : 3 , "D32" : 3 , "B33" : 4 , "C33" : 4 , "D33" : 4 , "B34" : 5 , "C34" : 5 , "D34" : 5 , "B35" : 6 , "C35" : 6 , "D35" : 6 , "B36" : 7 , "C36" : 7 , "D36" : 7 , "B37" : 8 , "C37" : 8 , "D37" : 8 }
for k , v := range categories {
assert . NoError ( t , f . SetCellValue ( "Sheet1" , k , v ) )
}
for k , v := range values {
assert . NoError ( t , f . SetCellValue ( "Sheet1" , k , v ) )
}
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
assert . EqualError ( t , f . AddChart ( "Sheet1" , "P1" , nil ) , ErrParameterInvalid . Error ( ) )
// Test add chart on not exists worksheet
assert . EqualError ( t , f . AddChart ( "SheetN" , "P1" , nil ) , "sheet SheetN does not exist" )
maximum , minimum , zero := 7.5 , 0.5 , .0
series := [ ] ChartSeries {
{ Name : "Sheet1!$A$30" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$30:$D$30" } ,
{ Name : "Sheet1!$A$31" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$31:$D$31" } ,
{ Name : "Sheet1!$A$32" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$32:$D$32" } ,
{ Name : "Sheet1!$A$33" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$33:$D$33" } ,
{ Name : "Sheet1!$A$34" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$34:$D$34" } ,
{ Name : "Sheet1!$A$35" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$35:$D$35" } ,
{ Name : "Sheet1!$A$36" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$36:$D$36" } ,
{ Name : "Sheet1!$A$37" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$37:$D$37" } ,
}
series2 := [ ] ChartSeries {
2023-02-22 22:46:36 +08:00
{
Name : "Sheet1!$A$30" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$30:$D$30" ,
2023-02-17 20:03:46 +08:00
Fill : Fill { Type : "pattern" , Color : [ ] string { "000000" } , Pattern : 1 } ,
2023-02-22 22:46:36 +08:00
Marker : ChartMarker { Symbol : "none" , Size : 10 } ,
} ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
{ Name : "Sheet1!$A$31" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$31:$D$31" } ,
{ Name : "Sheet1!$A$32" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$32:$D$32" } ,
{ Name : "Sheet1!$A$33" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$33:$D$33" } ,
{ Name : "Sheet1!$A$34" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$34:$D$34" } ,
{ Name : "Sheet1!$A$35" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$35:$D$35" } ,
{ Name : "Sheet1!$A$36" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$36:$D$36" } ,
{ Name : "Sheet1!$A$37" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$37:$D$37" , Line : ChartLine { Width : 0.25 } } ,
}
series3 := [ ] ChartSeries { { Name : "Sheet1!$A$30" , Categories : "Sheet1!$A$30:$D$37" , Values : "Sheet1!$B$30:$B$37" } }
2023-02-17 20:03:46 +08:00
series4 := [ ] ChartSeries {
{ Name : "Sheet1!$A$30" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$30:$D$30" , Sizes : "Sheet1!$B$30:$D$30" } ,
{ Name : "Sheet1!$A$31" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$31:$D$31" , Sizes : "Sheet1!$B$31:$D$31" } ,
{ Name : "Sheet1!$A$32" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$32:$D$32" , Sizes : "Sheet1!$B$32:$D$32" } ,
{ Name : "Sheet1!$A$33" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$33:$D$33" , Sizes : "Sheet1!$B$33:$D$33" } ,
{ Name : "Sheet1!$A$34" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$34:$D$34" , Sizes : "Sheet1!$B$34:$D$34" } ,
{ Name : "Sheet1!$A$35" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$35:$D$35" , Sizes : "Sheet1!$B$35:$D$35" } ,
{ Name : "Sheet1!$A$36" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$36:$D$36" , Sizes : "Sheet1!$B$36:$D$36" } ,
{ Name : "Sheet1!$A$37" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$37:$D$37" , Sizes : "Sheet1!$B$37:$D$37" } ,
}
2023-01-02 11:47:31 +08:00
format := GraphicOptions {
ScaleX : defaultPictureScale ,
ScaleY : defaultPictureScale ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
OffsetX : 15 ,
OffsetY : 10 ,
PrintObject : boolPtr ( true ) ,
LockAspectRatio : false ,
Locked : boolPtr ( false ) ,
}
2023-01-02 11:47:31 +08:00
legend := ChartLegend { Position : "left" , ShowLegendKey : false }
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
plotArea := ChartPlotArea {
2023-02-19 00:18:11 +08:00
SecondPlotValues : 3 ,
ShowBubbleSize : true ,
ShowCatName : true ,
ShowLeaderLines : false ,
ShowPercent : true ,
ShowSerName : true ,
ShowVal : true ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
}
for _ , c := range [ ] struct {
sheetName , cell string
opts * Chart
} {
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet1" , cell : "P1" , opts : & Chart { Type : Col , Series : series , Format : format , Legend : ChartLegend { Position : "none" , ShowLegendKey : true } , Title : ChartTitle { Name : "2D Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { Font : Font { Bold : true , Italic : true , Underline : "dbl" , Color : "000000" } } , YAxis : ChartAxis { Font : Font { Bold : false , Italic : false , Underline : "sng" , Color : "777777" } } } } ,
{ sheetName : "Sheet1" , cell : "X1" , opts : & Chart { Type : ColStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Stacked Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "P16" , opts : & Chart { Type : ColPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "100% Stacked Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "X16" , opts : & Chart { Type : Col3DClustered , Series : series , Format : format , Legend : ChartLegend { Position : "bottom" , ShowLegendKey : false } , Title : ChartTitle { Name : "3D Clustered Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "P30" , opts : & Chart { Type : Col3DStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Stacked Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "X30" , opts : & Chart { Type : Col3DPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D 100% Stacked Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "X45" , opts : & Chart { Type : Radar , Series : series , Format : format , Legend : ChartLegend { Position : "top_right" , ShowLegendKey : false } , Title : ChartTitle { Name : "Radar Chart" } , PlotArea : plotArea , ShowBlanksAs : "span" } } ,
{ sheetName : "Sheet1" , cell : "AF1" , opts : & Chart { Type : Col3DConeStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cone Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AF16" , opts : & Chart { Type : Col3DConeClustered , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cone Clustered Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AF30" , opts : & Chart { Type : Col3DConePercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cone Percent Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AF45" , opts : & Chart { Type : Col3DCone , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cone Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AN1" , opts : & Chart { Type : Col3DPyramidStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Pyramid Percent Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AN16" , opts : & Chart { Type : Col3DPyramidClustered , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Pyramid Clustered Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AN30" , opts : & Chart { Type : Col3DPyramidPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Pyramid Percent Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AN45" , opts : & Chart { Type : Col3DPyramid , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Pyramid Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AV1" , opts : & Chart { Type : Col3DCylinderStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cylinder Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AV16" , opts : & Chart { Type : Col3DCylinderClustered , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cylinder Clustered Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AV30" , opts : & Chart { Type : Col3DCylinderPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cylinder Percent Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "AV45" , opts : & Chart { Type : Col3DCylinder , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Cylinder Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet1" , cell : "P45" , opts : & Chart { Type : Col3D , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "P1" , opts : & Chart { Type : Line3D , Series : series2 , Format : format , Legend : ChartLegend { Position : "top" , ShowLegendKey : false } , Title : ChartTitle { Name : "3D Line Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { MajorGridLines : true , MinorGridLines : true , TickLabelSkip : 1 , NumFmt : ChartNumFmt { CustomNumFmt : "General" } } , YAxis : ChartAxis { MajorGridLines : true , MinorGridLines : true , MajorUnit : 1 , NumFmt : ChartNumFmt { CustomNumFmt : "General" } } } } ,
{ sheetName : "Sheet2" , cell : "X1" , opts : & Chart { Type : Scatter , Series : series , Format : format , Legend : ChartLegend { Position : "bottom" , ShowLegendKey : false } , Title : ChartTitle { Name : "Scatter Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "P16" , opts : & Chart { Type : Doughnut , Series : series3 , Format : format , Legend : ChartLegend { Position : "right" , ShowLegendKey : false } , Title : ChartTitle { Name : "Doughnut Chart" } , PlotArea : ChartPlotArea { ShowBubbleSize : false , ShowCatName : false , ShowLeaderLines : false , ShowPercent : true , ShowSerName : false , ShowVal : false } , ShowBlanksAs : "zero" , HoleSize : 30 } } ,
{ sheetName : "Sheet2" , cell : "X16" , opts : & Chart { Type : Line , Series : series2 , Format : format , Legend : ChartLegend { Position : "top" , ShowLegendKey : false } , Title : ChartTitle { Name : "Line Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { MajorGridLines : true , MinorGridLines : true , TickLabelSkip : 1 } , YAxis : ChartAxis { MajorGridLines : true , MinorGridLines : true , MajorUnit : 1 } } } ,
{ sheetName : "Sheet2" , cell : "P32" , opts : & Chart { Type : Pie3D , Series : series3 , Format : format , Legend : ChartLegend { Position : "bottom" , ShowLegendKey : false } , Title : ChartTitle { Name : "3D Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "X32" , opts : & Chart { Type : Pie , Series : series3 , Format : format , Legend : ChartLegend { Position : "bottom" , ShowLegendKey : false } , Title : ChartTitle { Name : "Pie Chart" } , PlotArea : ChartPlotArea { ShowBubbleSize : true , ShowCatName : false , ShowLeaderLines : false , ShowPercent : true , ShowSerName : false , ShowVal : false , NumFmt : ChartNumFmt { CustomNumFmt : "0.00%;0;;" } } , ShowBlanksAs : "gap" } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// bar series chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "P48" , opts : & Chart { Type : Bar , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Clustered Bar Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "X48" , opts : & Chart { Type : BarStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Stacked Bar Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "P64" , opts : & Chart { Type : BarPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Stacked 100% Bar Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "X64" , opts : & Chart { Type : Bar3DClustered , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Clustered Bar Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "P80" , opts : & Chart { Type : Bar3DStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Stacked Bar Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , YAxis : ChartAxis { Maximum : & maximum , Minimum : & minimum } } } ,
{ sheetName : "Sheet2" , cell : "X80" , opts : & Chart { Type : Bar3DPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D 100% Stacked Bar Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { ReverseOrder : true , Minimum : & zero } , YAxis : ChartAxis { ReverseOrder : true , Minimum : & zero } } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// area series chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "AF1" , opts : & Chart { Type : Area , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Area Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AN1" , opts : & Chart { Type : AreaStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Stacked Area Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AF16" , opts : & Chart { Type : AreaPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D 100% Stacked Area Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AN16" , opts : & Chart { Type : Area3D , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Area Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AF32" , opts : & Chart { Type : Area3DStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Stacked Area Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AN32" , opts : & Chart { Type : Area3DPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D 100% Stacked Area Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// cylinder series chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "AF48" , opts : & Chart { Type : Bar3DCylinderStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Cylinder Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AF64" , opts : & Chart { Type : Bar3DCylinderClustered , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Cylinder Clustered Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AF80" , opts : & Chart { Type : Bar3DCylinderPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Cylinder Percent Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// cone series chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "AN48" , opts : & Chart { Type : Bar3DConeStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Cone Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AN64" , opts : & Chart { Type : Bar3DConeClustered , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Cone Clustered Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AN80" , opts : & Chart { Type : Bar3DConePercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Cone Percent Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AV48" , opts : & Chart { Type : Bar3DPyramidStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Pyramid Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AV64" , opts : & Chart { Type : Bar3DPyramidClustered , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Pyramid Clustered Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "AV80" , opts : & Chart { Type : Bar3DPyramidPercentStacked , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Bar Pyramid Percent Stacked Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// surface series chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "AV1" , opts : & Chart { Type : Surface3D , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Surface Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , YAxis : ChartAxis { MajorGridLines : true } } } ,
{ sheetName : "Sheet2" , cell : "AV16" , opts : & Chart { Type : WireframeSurface3D , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "3D Wireframe Surface Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , YAxis : ChartAxis { MajorGridLines : true } } } ,
{ sheetName : "Sheet2" , cell : "AV32" , opts : & Chart { Type : Contour , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "Contour Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "BD1" , opts : & Chart { Type : WireframeContour , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "Wireframe Contour Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// bubble chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "BD16" , opts : & Chart { Type : Bubble , Series : series4 , Format : format , Legend : legend , Title : ChartTitle { Name : "Bubble Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } } ,
{ sheetName : "Sheet2" , cell : "BD32" , opts : & Chart { Type : Bubble3D , Series : series4 , Format : format , Legend : legend , Title : ChartTitle { Name : "Bubble 3D Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { MajorGridLines : true } , YAxis : ChartAxis { MajorGridLines : true } } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// pie of pie chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "BD48" , opts : & Chart { Type : PieOfPie , Series : series3 , Format : format , Legend : legend , Title : ChartTitle { Name : "Pie of Pie Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { MajorGridLines : true } , YAxis : ChartAxis { MajorGridLines : true } } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
// bar of pie chart
2023-04-01 00:08:53 +08:00
{ sheetName : "Sheet2" , cell : "BD64" , opts : & Chart { Type : BarOfPie , Series : series3 , Format : format , Legend : legend , Title : ChartTitle { Name : "Bar of Pie Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { MajorGridLines : true } , YAxis : ChartAxis { MajorGridLines : true } } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
} {
assert . NoError ( t , f . AddChart ( c . sheetName , c . cell , c . opts ) )
}
2020-01-14 00:33:36 +08:00
// combo chart
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
_ , err = f . NewSheet ( "Combo Charts" )
assert . NoError ( t , err )
2023-04-01 00:08:53 +08:00
clusteredColumnCombo := [ ] [ ] interface { } {
{ "A1" , Line , "Clustered Column - Line Chart" } ,
{ "I1" , Doughnut , "Clustered Column - Doughnut Chart" } ,
2020-01-14 00:33:36 +08:00
}
2020-12-27 00:18:54 +08:00
for _ , props := range clusteredColumnCombo {
2023-04-01 00:08:53 +08:00
assert . NoError ( t , f . AddChart ( "Combo Charts" , props [ 0 ] . ( string ) , & Chart { Type : Col , Series : series [ : 4 ] , Format : format , Legend : legend , Title : ChartTitle { Name : props [ 2 ] . ( string ) } , PlotArea : ChartPlotArea { ShowBubbleSize : true , ShowCatName : false , ShowLeaderLines : false , ShowPercent : true , ShowSerName : true , ShowVal : true } } , & Chart { Type : props [ 1 ] . ( ChartType ) , Series : series [ 4 : ] , Format : format , Legend : legend , PlotArea : ChartPlotArea { ShowBubbleSize : true , ShowCatName : false , ShowLeaderLines : false , ShowPercent : true , ShowSerName : true , ShowVal : true } } ) )
2020-01-14 00:33:36 +08:00
}
2023-04-01 00:08:53 +08:00
stackedAreaCombo := map [ string ] [ ] interface { } {
"A16" : { Line , "Stacked Area - Line Chart" } ,
"I16" : { Doughnut , "Stacked Area - Doughnut Chart" } ,
2020-01-14 00:33:36 +08:00
}
for axis , props := range stackedAreaCombo {
2023-04-01 00:08:53 +08:00
assert . NoError ( t , f . AddChart ( "Combo Charts" , axis , & Chart { Type : AreaStacked , Series : series [ : 4 ] , Format : format , Legend : legend , Title : ChartTitle { Name : props [ 1 ] . ( string ) } , PlotArea : ChartPlotArea { ShowBubbleSize : true , ShowCatName : false , ShowLeaderLines : false , ShowPercent : true , ShowSerName : true , ShowVal : true } } , & Chart { Type : props [ 0 ] . ( ChartType ) , Series : series [ 4 : ] , Format : format , Legend : legend , PlotArea : ChartPlotArea { ShowBubbleSize : true , ShowCatName : false , ShowLeaderLines : false , ShowPercent : true , ShowSerName : true , ShowVal : true } } ) )
2020-01-14 00:33:36 +08:00
}
2019-06-09 09:53:02 +08:00
assert . NoError ( t , f . SaveAs ( filepath . Join ( "test" , "TestAddChart.xlsx" ) ) )
This closes #1425, breaking changes for sheet name (#1426)
- Checking and return error for invalid sheet name instead of trim invalid characters
- Add error return for the 4 functions: `DeleteSheet`, `GetSheetIndex`, `GetSheetVisible` and `SetSheetName`
- Export new error 4 constants: `ErrSheetNameBlank`, `ErrSheetNameInvalid`, `ErrSheetNameLength` and `ErrSheetNameSingleQuote`
- Rename exported error constant `ErrExistsWorksheet` to `ErrExistsSheet`
- Update unit tests for 90 functions: `AddChart`, `AddChartSheet`, `AddComment`, `AddDataValidation`, `AddPicture`, `AddPictureFromBytes`, `AddPivotTable`, `AddShape`, `AddSparkline`, `AddTable`, `AutoFilter`, `CalcCellValue`, `Cols`, `DeleteChart`, `DeleteComment`, `DeleteDataValidation`, `DeletePicture`, `DeleteSheet`, `DuplicateRow`, `DuplicateRowTo`, `GetCellFormula`, `GetCellHyperLink`, `GetCellRichText`, `GetCellStyle`, `GetCellType`, `GetCellValue`, `GetColOutlineLevel`, `GetCols`, `GetColStyle`, `GetColVisible`, `GetColWidth`, `GetConditionalFormats`, `GetDataValidations`, `GetMergeCells`, `GetPageLayout`, `GetPageMargins`, `GetPicture`, `GetRowHeight`, `GetRowOutlineLevel`, `GetRows`, `GetRowVisible`, `GetSheetIndex`, `GetSheetProps`, `GetSheetVisible`, `GroupSheets`, `InsertCol`, `InsertPageBreak`, `InsertRows`, `MergeCell`, `NewSheet`, `NewStreamWriter`, `ProtectSheet`, `RemoveCol`, `RemovePageBreak`, `RemoveRow`, `Rows`, `SearchSheet`, `SetCellBool`, `SetCellDefault`, `SetCellFloat`, `SetCellFormula`, `SetCellHyperLink`, `SetCellInt`, `SetCellRichText`, `SetCellStr`, `SetCellStyle`, `SetCellValue`, `SetColOutlineLevel`, `SetColStyle`, `SetColVisible`, `SetColWidth`, `SetConditionalFormat`, `SetHeaderFooter`, `SetPageLayout`, `SetPageMargins`, `SetPanes`, `SetRowHeight`, `SetRowOutlineLevel`, `SetRowStyle`, `SetRowVisible`, `SetSheetBackground`, `SetSheetBackgroundFromBytes`, `SetSheetCol`, `SetSheetName`, `SetSheetProps`, `SetSheetRow`, `SetSheetVisible`, `UnmergeCell`, `UnprotectSheet` and
`UnsetConditionalFormat`
- Update documentation of the set style functions
Co-authored-by: guoweikuang <weikuang.guo@shopee.com>
2022-12-23 00:54:40 +08:00
// Test with invalid sheet name
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChart ( "Sheet:1" , "A1" , & Chart { Type : Col , Series : series [ : 1 ] } ) , ErrSheetNameInvalid . Error ( ) )
2022-09-18 00:07:15 +08:00
// Test with illegal cell reference
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChart ( "Sheet2" , "A" , & Chart { Type : Col , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } ) , newCellNameToCoordinatesError ( "A" , newInvalidCellNameError ( "A" ) ) . Error ( ) )
2020-01-14 00:33:36 +08:00
// Test with unsupported chart type
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChart ( "Sheet2" , "BD32" , & Chart { Type : 0x37 , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "Bubble 3D Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } ) , newUnsupportedChartType ( 0x37 ) . Error ( ) )
2020-03-28 23:47:26 +08:00
// Test add combo chart with invalid format set
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChart ( "Sheet2" , "BD32" , & Chart { Type : Col , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } , nil ) , ErrParameterInvalid . Error ( ) )
2020-03-28 23:47:26 +08:00
// Test add combo chart with unsupported chart type
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChart ( "Sheet2" , "BD64" , & Chart { Type : BarOfPie , Series : [ ] ChartSeries { { Name : "Sheet1!$A$30" , Categories : "Sheet1!$A$30:$D$37" , Values : "Sheet1!$B$30:$B$37" } } , Format : format , Legend : legend , Title : ChartTitle { Name : "Bar of Pie Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { MajorGridLines : true } , YAxis : ChartAxis { MajorGridLines : true } } , & Chart { Type : 0x37 , Series : [ ] ChartSeries { { Name : "Sheet1!$A$30" , Categories : "Sheet1!$A$30:$D$37" , Values : "Sheet1!$B$30:$B$37" } } , Format : format , Legend : legend , Title : ChartTitle { Name : "Bar of Pie Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" , XAxis : ChartAxis { MajorGridLines : true } , YAxis : ChartAxis { MajorGridLines : true } } ) , newUnsupportedChartType ( 0x37 ) . Error ( ) )
2021-09-18 23:20:24 +08:00
assert . NoError ( t , f . Close ( ) )
2022-11-13 00:40:04 +08:00
// Test add chart with unsupported charset content types.
f . ContentTypes = nil
f . Pkg . Store ( defaultXMLPathContentTypes , MacintoshCyrillicCharset )
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChart ( "Sheet1" , "P1" , & Chart { Type : Col , Series : [ ] ChartSeries { { Name : "Sheet1!$A$30" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$30:$D$30" } } , Title : ChartTitle { Name : "2D Column Chart" } } ) , "XML syntax error on line 1: invalid UTF-8" )
2019-06-09 09:53:02 +08:00
}
2020-01-19 00:23:00 +08:00
2020-03-28 23:47:26 +08:00
func TestAddChartSheet ( t * testing . T ) {
categories := map [ string ] string { "A2" : "Small" , "A3" : "Normal" , "A4" : "Large" , "B1" : "Apple" , "C1" : "Orange" , "D1" : "Pear" }
values := map [ string ] int { "B2" : 2 , "C2" : 3 , "D2" : 3 , "B3" : 5 , "C3" : 2 , "D3" : 4 , "B4" : 6 , "C4" : 7 , "D4" : 8 }
f := NewFile ( )
for k , v := range categories {
assert . NoError ( t , f . SetCellValue ( "Sheet1" , k , v ) )
}
for k , v := range values {
assert . NoError ( t , f . SetCellValue ( "Sheet1" , k , v ) )
}
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
series := [ ] ChartSeries {
{ Name : "Sheet1!$A$2" , Categories : "Sheet1!$B$1:$D$1" , Values : "Sheet1!$B$2:$D$2" } ,
{ Name : "Sheet1!$A$3" , Categories : "Sheet1!$B$1:$D$1" , Values : "Sheet1!$B$3:$D$3" } ,
{ Name : "Sheet1!$A$4" , Categories : "Sheet1!$B$1:$D$1" , Values : "Sheet1!$B$4:$D$4" } ,
}
2023-04-01 00:08:53 +08:00
assert . NoError ( t , f . AddChartSheet ( "Chart1" , & Chart { Type : Col3DClustered , Series : series , Title : ChartTitle { Name : "Fruit 3D Clustered Column Chart" } } ) )
2020-03-29 18:44:24 +08:00
// Test set the chartsheet as active sheet
2020-04-23 02:01:14 +08:00
var sheetIdx int
for idx , sheetName := range f . GetSheetList ( ) {
2020-03-29 18:44:24 +08:00
if sheetName != "Chart1" {
continue
}
2020-04-23 02:01:14 +08:00
sheetIdx = idx
2020-03-29 18:44:24 +08:00
}
2020-04-23 02:01:14 +08:00
f . SetActiveSheet ( sheetIdx )
2020-03-29 18:44:24 +08:00
// Test cell value on chartsheet
2021-09-06 00:01:42 +08:00
assert . EqualError ( t , f . SetCellValue ( "Chart1" , "A1" , true ) , "sheet Chart1 is not a worksheet" )
2020-03-29 18:44:24 +08:00
// Test add chartsheet on already existing name sheet
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChartSheet ( "Sheet1" , & Chart { Type : Col3DClustered , Series : series , Title : ChartTitle { Name : "Fruit 3D Clustered Column Chart" } } ) , ErrExistsSheet . Error ( ) )
This closes #1425, breaking changes for sheet name (#1426)
- Checking and return error for invalid sheet name instead of trim invalid characters
- Add error return for the 4 functions: `DeleteSheet`, `GetSheetIndex`, `GetSheetVisible` and `SetSheetName`
- Export new error 4 constants: `ErrSheetNameBlank`, `ErrSheetNameInvalid`, `ErrSheetNameLength` and `ErrSheetNameSingleQuote`
- Rename exported error constant `ErrExistsWorksheet` to `ErrExistsSheet`
- Update unit tests for 90 functions: `AddChart`, `AddChartSheet`, `AddComment`, `AddDataValidation`, `AddPicture`, `AddPictureFromBytes`, `AddPivotTable`, `AddShape`, `AddSparkline`, `AddTable`, `AutoFilter`, `CalcCellValue`, `Cols`, `DeleteChart`, `DeleteComment`, `DeleteDataValidation`, `DeletePicture`, `DeleteSheet`, `DuplicateRow`, `DuplicateRowTo`, `GetCellFormula`, `GetCellHyperLink`, `GetCellRichText`, `GetCellStyle`, `GetCellType`, `GetCellValue`, `GetColOutlineLevel`, `GetCols`, `GetColStyle`, `GetColVisible`, `GetColWidth`, `GetConditionalFormats`, `GetDataValidations`, `GetMergeCells`, `GetPageLayout`, `GetPageMargins`, `GetPicture`, `GetRowHeight`, `GetRowOutlineLevel`, `GetRows`, `GetRowVisible`, `GetSheetIndex`, `GetSheetProps`, `GetSheetVisible`, `GroupSheets`, `InsertCol`, `InsertPageBreak`, `InsertRows`, `MergeCell`, `NewSheet`, `NewStreamWriter`, `ProtectSheet`, `RemoveCol`, `RemovePageBreak`, `RemoveRow`, `Rows`, `SearchSheet`, `SetCellBool`, `SetCellDefault`, `SetCellFloat`, `SetCellFormula`, `SetCellHyperLink`, `SetCellInt`, `SetCellRichText`, `SetCellStr`, `SetCellStyle`, `SetCellValue`, `SetColOutlineLevel`, `SetColStyle`, `SetColVisible`, `SetColWidth`, `SetConditionalFormat`, `SetHeaderFooter`, `SetPageLayout`, `SetPageMargins`, `SetPanes`, `SetRowHeight`, `SetRowOutlineLevel`, `SetRowStyle`, `SetRowVisible`, `SetSheetBackground`, `SetSheetBackgroundFromBytes`, `SetSheetCol`, `SetSheetName`, `SetSheetProps`, `SetSheetRow`, `SetSheetVisible`, `UnmergeCell`, `UnprotectSheet` and
`UnsetConditionalFormat`
- Update documentation of the set style functions
Co-authored-by: guoweikuang <weikuang.guo@shopee.com>
2022-12-23 00:54:40 +08:00
// Test add chartsheet with invalid sheet name
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChartSheet ( "Sheet:1" , nil , & Chart { Type : Col3DClustered , Series : series , Title : ChartTitle { Name : "Fruit 3D Clustered Column Chart" } } ) , ErrSheetNameInvalid . Error ( ) )
2020-03-28 23:47:26 +08:00
// Test with unsupported chart type
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChartSheet ( "Chart2" , & Chart { Type : 0x37 , Series : series , Title : ChartTitle { Name : "Fruit 3D Clustered Column Chart" } } ) , newUnsupportedChartType ( 0x37 ) . Error ( ) )
2020-03-28 23:47:26 +08:00
2021-03-04 09:23:45 +08:00
assert . NoError ( t , f . UpdateLinkedValue ( ) )
2020-03-28 23:47:26 +08:00
assert . NoError ( t , f . SaveAs ( filepath . Join ( "test" , "TestAddChartSheet.xlsx" ) ) )
This closes #1425, breaking changes for sheet name (#1426)
- Checking and return error for invalid sheet name instead of trim invalid characters
- Add error return for the 4 functions: `DeleteSheet`, `GetSheetIndex`, `GetSheetVisible` and `SetSheetName`
- Export new error 4 constants: `ErrSheetNameBlank`, `ErrSheetNameInvalid`, `ErrSheetNameLength` and `ErrSheetNameSingleQuote`
- Rename exported error constant `ErrExistsWorksheet` to `ErrExistsSheet`
- Update unit tests for 90 functions: `AddChart`, `AddChartSheet`, `AddComment`, `AddDataValidation`, `AddPicture`, `AddPictureFromBytes`, `AddPivotTable`, `AddShape`, `AddSparkline`, `AddTable`, `AutoFilter`, `CalcCellValue`, `Cols`, `DeleteChart`, `DeleteComment`, `DeleteDataValidation`, `DeletePicture`, `DeleteSheet`, `DuplicateRow`, `DuplicateRowTo`, `GetCellFormula`, `GetCellHyperLink`, `GetCellRichText`, `GetCellStyle`, `GetCellType`, `GetCellValue`, `GetColOutlineLevel`, `GetCols`, `GetColStyle`, `GetColVisible`, `GetColWidth`, `GetConditionalFormats`, `GetDataValidations`, `GetMergeCells`, `GetPageLayout`, `GetPageMargins`, `GetPicture`, `GetRowHeight`, `GetRowOutlineLevel`, `GetRows`, `GetRowVisible`, `GetSheetIndex`, `GetSheetProps`, `GetSheetVisible`, `GroupSheets`, `InsertCol`, `InsertPageBreak`, `InsertRows`, `MergeCell`, `NewSheet`, `NewStreamWriter`, `ProtectSheet`, `RemoveCol`, `RemovePageBreak`, `RemoveRow`, `Rows`, `SearchSheet`, `SetCellBool`, `SetCellDefault`, `SetCellFloat`, `SetCellFormula`, `SetCellHyperLink`, `SetCellInt`, `SetCellRichText`, `SetCellStr`, `SetCellStyle`, `SetCellValue`, `SetColOutlineLevel`, `SetColStyle`, `SetColVisible`, `SetColWidth`, `SetConditionalFormat`, `SetHeaderFooter`, `SetPageLayout`, `SetPageMargins`, `SetPanes`, `SetRowHeight`, `SetRowOutlineLevel`, `SetRowStyle`, `SetRowVisible`, `SetSheetBackground`, `SetSheetBackgroundFromBytes`, `SetSheetCol`, `SetSheetName`, `SetSheetProps`, `SetSheetRow`, `SetSheetVisible`, `UnmergeCell`, `UnprotectSheet` and
`UnsetConditionalFormat`
- Update documentation of the set style functions
Co-authored-by: guoweikuang <weikuang.guo@shopee.com>
2022-12-23 00:54:40 +08:00
// Test add chart sheet with unsupported charset content types
2022-11-13 00:40:04 +08:00
f = NewFile ( )
f . ContentTypes = nil
f . Pkg . Store ( defaultXMLPathContentTypes , MacintoshCyrillicCharset )
2023-04-01 00:08:53 +08:00
assert . EqualError ( t , f . AddChartSheet ( "Chart4" , & Chart { Type : Col , Series : [ ] ChartSeries { { Name : "Sheet1!$A$30" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$30:$D$30" } } , Title : ChartTitle { Name : "2D Column Chart" } } ) , "XML syntax error on line 1: invalid UTF-8" )
2020-03-28 23:47:26 +08:00
}
2020-01-19 00:23:00 +08:00
func TestDeleteChart ( t * testing . T ) {
f , err := OpenFile ( filepath . Join ( "test" , "Book1.xlsx" ) )
assert . NoError ( t , err )
assert . NoError ( t , f . DeleteChart ( "Sheet1" , "A1" ) )
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
series := [ ] ChartSeries {
{ Name : "Sheet1!$A$30" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$30:$D$30" } ,
{ Name : "Sheet1!$A$31" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$31:$D$31" } ,
{ Name : "Sheet1!$A$32" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$32:$D$32" } ,
{ Name : "Sheet1!$A$33" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$33:$D$33" } ,
{ Name : "Sheet1!$A$34" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$34:$D$34" } ,
{ Name : "Sheet1!$A$35" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$35:$D$35" } ,
{ Name : "Sheet1!$A$36" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$36:$D$36" } ,
{ Name : "Sheet1!$A$37" , Categories : "Sheet1!$B$29:$D$29" , Values : "Sheet1!$B$37:$D$37" } ,
}
2023-01-02 11:47:31 +08:00
format := GraphicOptions {
ScaleX : defaultPictureScale ,
ScaleY : defaultPictureScale ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
OffsetX : 15 ,
OffsetY : 10 ,
PrintObject : boolPtr ( true ) ,
LockAspectRatio : false ,
Locked : boolPtr ( false ) ,
}
2023-01-02 11:47:31 +08:00
legend := ChartLegend { Position : "left" , ShowLegendKey : false }
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
plotArea := ChartPlotArea {
ShowBubbleSize : true ,
ShowCatName : true ,
ShowLeaderLines : false ,
ShowPercent : true ,
ShowSerName : true ,
ShowVal : true ,
}
2023-04-01 00:08:53 +08:00
assert . NoError ( t , f . AddChart ( "Sheet1" , "P1" , & Chart { Type : Col , Series : series , Format : format , Legend : legend , Title : ChartTitle { Name : "2D Column Chart" } , PlotArea : plotArea , ShowBlanksAs : "zero" } ) )
2020-01-19 00:23:00 +08:00
assert . NoError ( t , f . DeleteChart ( "Sheet1" , "P1" ) )
assert . NoError ( t , f . SaveAs ( filepath . Join ( "test" , "TestDeleteChart.xlsx" ) ) )
This closes #1425, breaking changes for sheet name (#1426)
- Checking and return error for invalid sheet name instead of trim invalid characters
- Add error return for the 4 functions: `DeleteSheet`, `GetSheetIndex`, `GetSheetVisible` and `SetSheetName`
- Export new error 4 constants: `ErrSheetNameBlank`, `ErrSheetNameInvalid`, `ErrSheetNameLength` and `ErrSheetNameSingleQuote`
- Rename exported error constant `ErrExistsWorksheet` to `ErrExistsSheet`
- Update unit tests for 90 functions: `AddChart`, `AddChartSheet`, `AddComment`, `AddDataValidation`, `AddPicture`, `AddPictureFromBytes`, `AddPivotTable`, `AddShape`, `AddSparkline`, `AddTable`, `AutoFilter`, `CalcCellValue`, `Cols`, `DeleteChart`, `DeleteComment`, `DeleteDataValidation`, `DeletePicture`, `DeleteSheet`, `DuplicateRow`, `DuplicateRowTo`, `GetCellFormula`, `GetCellHyperLink`, `GetCellRichText`, `GetCellStyle`, `GetCellType`, `GetCellValue`, `GetColOutlineLevel`, `GetCols`, `GetColStyle`, `GetColVisible`, `GetColWidth`, `GetConditionalFormats`, `GetDataValidations`, `GetMergeCells`, `GetPageLayout`, `GetPageMargins`, `GetPicture`, `GetRowHeight`, `GetRowOutlineLevel`, `GetRows`, `GetRowVisible`, `GetSheetIndex`, `GetSheetProps`, `GetSheetVisible`, `GroupSheets`, `InsertCol`, `InsertPageBreak`, `InsertRows`, `MergeCell`, `NewSheet`, `NewStreamWriter`, `ProtectSheet`, `RemoveCol`, `RemovePageBreak`, `RemoveRow`, `Rows`, `SearchSheet`, `SetCellBool`, `SetCellDefault`, `SetCellFloat`, `SetCellFormula`, `SetCellHyperLink`, `SetCellInt`, `SetCellRichText`, `SetCellStr`, `SetCellStyle`, `SetCellValue`, `SetColOutlineLevel`, `SetColStyle`, `SetColVisible`, `SetColWidth`, `SetConditionalFormat`, `SetHeaderFooter`, `SetPageLayout`, `SetPageMargins`, `SetPanes`, `SetRowHeight`, `SetRowOutlineLevel`, `SetRowStyle`, `SetRowVisible`, `SetSheetBackground`, `SetSheetBackgroundFromBytes`, `SetSheetCol`, `SetSheetName`, `SetSheetProps`, `SetSheetRow`, `SetSheetVisible`, `UnmergeCell`, `UnprotectSheet` and
`UnsetConditionalFormat`
- Update documentation of the set style functions
Co-authored-by: guoweikuang <weikuang.guo@shopee.com>
2022-12-23 00:54:40 +08:00
// Test delete chart with invalid sheet name
assert . EqualError ( t , f . DeleteChart ( "Sheet:1" , "P1" ) , ErrSheetNameInvalid . Error ( ) )
// Test delete chart on not exists worksheet
2022-08-28 00:16:41 +08:00
assert . EqualError ( t , f . DeleteChart ( "SheetN" , "A1" ) , "sheet SheetN does not exist" )
This closes #1425, breaking changes for sheet name (#1426)
- Checking and return error for invalid sheet name instead of trim invalid characters
- Add error return for the 4 functions: `DeleteSheet`, `GetSheetIndex`, `GetSheetVisible` and `SetSheetName`
- Export new error 4 constants: `ErrSheetNameBlank`, `ErrSheetNameInvalid`, `ErrSheetNameLength` and `ErrSheetNameSingleQuote`
- Rename exported error constant `ErrExistsWorksheet` to `ErrExistsSheet`
- Update unit tests for 90 functions: `AddChart`, `AddChartSheet`, `AddComment`, `AddDataValidation`, `AddPicture`, `AddPictureFromBytes`, `AddPivotTable`, `AddShape`, `AddSparkline`, `AddTable`, `AutoFilter`, `CalcCellValue`, `Cols`, `DeleteChart`, `DeleteComment`, `DeleteDataValidation`, `DeletePicture`, `DeleteSheet`, `DuplicateRow`, `DuplicateRowTo`, `GetCellFormula`, `GetCellHyperLink`, `GetCellRichText`, `GetCellStyle`, `GetCellType`, `GetCellValue`, `GetColOutlineLevel`, `GetCols`, `GetColStyle`, `GetColVisible`, `GetColWidth`, `GetConditionalFormats`, `GetDataValidations`, `GetMergeCells`, `GetPageLayout`, `GetPageMargins`, `GetPicture`, `GetRowHeight`, `GetRowOutlineLevel`, `GetRows`, `GetRowVisible`, `GetSheetIndex`, `GetSheetProps`, `GetSheetVisible`, `GroupSheets`, `InsertCol`, `InsertPageBreak`, `InsertRows`, `MergeCell`, `NewSheet`, `NewStreamWriter`, `ProtectSheet`, `RemoveCol`, `RemovePageBreak`, `RemoveRow`, `Rows`, `SearchSheet`, `SetCellBool`, `SetCellDefault`, `SetCellFloat`, `SetCellFormula`, `SetCellHyperLink`, `SetCellInt`, `SetCellRichText`, `SetCellStr`, `SetCellStyle`, `SetCellValue`, `SetColOutlineLevel`, `SetColStyle`, `SetColVisible`, `SetColWidth`, `SetConditionalFormat`, `SetHeaderFooter`, `SetPageLayout`, `SetPageMargins`, `SetPanes`, `SetRowHeight`, `SetRowOutlineLevel`, `SetRowStyle`, `SetRowVisible`, `SetSheetBackground`, `SetSheetBackgroundFromBytes`, `SetSheetCol`, `SetSheetName`, `SetSheetProps`, `SetSheetRow`, `SetSheetVisible`, `UnmergeCell`, `UnprotectSheet` and
`UnsetConditionalFormat`
- Update documentation of the set style functions
Co-authored-by: guoweikuang <weikuang.guo@shopee.com>
2022-12-23 00:54:40 +08:00
// Test delete chart with invalid coordinates
2021-12-07 00:26:53 +08:00
assert . EqualError ( t , f . DeleteChart ( "Sheet1" , "" ) , newCellNameToCoordinatesError ( "" , newInvalidCellNameError ( "" ) ) . Error ( ) )
This closes #1425, breaking changes for sheet name (#1426)
- Checking and return error for invalid sheet name instead of trim invalid characters
- Add error return for the 4 functions: `DeleteSheet`, `GetSheetIndex`, `GetSheetVisible` and `SetSheetName`
- Export new error 4 constants: `ErrSheetNameBlank`, `ErrSheetNameInvalid`, `ErrSheetNameLength` and `ErrSheetNameSingleQuote`
- Rename exported error constant `ErrExistsWorksheet` to `ErrExistsSheet`
- Update unit tests for 90 functions: `AddChart`, `AddChartSheet`, `AddComment`, `AddDataValidation`, `AddPicture`, `AddPictureFromBytes`, `AddPivotTable`, `AddShape`, `AddSparkline`, `AddTable`, `AutoFilter`, `CalcCellValue`, `Cols`, `DeleteChart`, `DeleteComment`, `DeleteDataValidation`, `DeletePicture`, `DeleteSheet`, `DuplicateRow`, `DuplicateRowTo`, `GetCellFormula`, `GetCellHyperLink`, `GetCellRichText`, `GetCellStyle`, `GetCellType`, `GetCellValue`, `GetColOutlineLevel`, `GetCols`, `GetColStyle`, `GetColVisible`, `GetColWidth`, `GetConditionalFormats`, `GetDataValidations`, `GetMergeCells`, `GetPageLayout`, `GetPageMargins`, `GetPicture`, `GetRowHeight`, `GetRowOutlineLevel`, `GetRows`, `GetRowVisible`, `GetSheetIndex`, `GetSheetProps`, `GetSheetVisible`, `GroupSheets`, `InsertCol`, `InsertPageBreak`, `InsertRows`, `MergeCell`, `NewSheet`, `NewStreamWriter`, `ProtectSheet`, `RemoveCol`, `RemovePageBreak`, `RemoveRow`, `Rows`, `SearchSheet`, `SetCellBool`, `SetCellDefault`, `SetCellFloat`, `SetCellFormula`, `SetCellHyperLink`, `SetCellInt`, `SetCellRichText`, `SetCellStr`, `SetCellStyle`, `SetCellValue`, `SetColOutlineLevel`, `SetColStyle`, `SetColVisible`, `SetColWidth`, `SetConditionalFormat`, `SetHeaderFooter`, `SetPageLayout`, `SetPageMargins`, `SetPanes`, `SetRowHeight`, `SetRowOutlineLevel`, `SetRowStyle`, `SetRowVisible`, `SetSheetBackground`, `SetSheetBackgroundFromBytes`, `SetSheetCol`, `SetSheetName`, `SetSheetProps`, `SetSheetRow`, `SetSheetVisible`, `UnmergeCell`, `UnprotectSheet` and
`UnsetConditionalFormat`
- Update documentation of the set style functions
Co-authored-by: guoweikuang <weikuang.guo@shopee.com>
2022-12-23 00:54:40 +08:00
// Test delete chart on no chart worksheet
2020-01-19 00:23:00 +08:00
assert . NoError ( t , NewFile ( ) . DeleteChart ( "Sheet1" , "A1" ) )
2021-09-18 23:20:24 +08:00
assert . NoError ( t , f . Close ( ) )
2020-01-19 00:23:00 +08:00
}
2020-07-11 01:07:41 +08:00
func TestChartWithLogarithmicBase ( t * testing . T ) {
// Create test XLSX file with data
2020-11-10 23:48:09 +08:00
f := NewFile ( )
sheet1 := f . GetSheetName ( 0 )
2020-07-11 01:07:41 +08:00
categories := map [ string ] float64 {
"A1" : 1 ,
"A2" : 2 ,
"A3" : 3 ,
"A4" : 4 ,
"A5" : 5 ,
"A6" : 6 ,
"A7" : 7 ,
"A8" : 8 ,
"A9" : 9 ,
"A10" : 10 ,
"B1" : 0.1 ,
"B2" : 1 ,
"B3" : 2 ,
"B4" : 3 ,
"B5" : 20 ,
"B6" : 30 ,
"B7" : 100 ,
"B8" : 500 ,
"B9" : 700 ,
"B10" : 5000 ,
}
for cell , v := range categories {
2020-11-10 23:48:09 +08:00
assert . NoError ( t , f . SetCellValue ( sheet1 , cell , v ) )
2020-07-11 01:07:41 +08:00
}
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
series := [ ] ChartSeries { { Name : "value" , Categories : "Sheet1!$A$1:$A$19" , Values : "Sheet1!$B$1:$B$10" } }
2023-01-02 11:47:31 +08:00
dimension := [ ] uint { 640 , 480 , 320 , 240 }
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
for _ , c := range [ ] struct {
cell string
opts * Chart
} {
2023-04-01 00:08:53 +08:00
{ cell : "C1" , opts : & Chart { Type : Line , Dimension : ChartDimension { Width : dimension [ 0 ] , Height : dimension [ 1 ] } , Series : series , Title : ChartTitle { Name : "Line chart without log scaling" } } } ,
{ cell : "M1" , opts : & Chart { Type : Line , Dimension : ChartDimension { Width : dimension [ 0 ] , Height : dimension [ 1 ] } , Series : series , Title : ChartTitle { Name : "Line chart with log 10.5 scaling" } , YAxis : ChartAxis { LogBase : 10.5 } } } ,
{ cell : "A25" , opts : & Chart { Type : Line , Dimension : ChartDimension { Width : dimension [ 2 ] , Height : dimension [ 3 ] } , Series : series , Title : ChartTitle { Name : "Line chart with log 1.9 scaling" } , YAxis : ChartAxis { LogBase : 1.9 } } } ,
{ cell : "F25" , opts : & Chart { Type : Line , Dimension : ChartDimension { Width : dimension [ 2 ] , Height : dimension [ 3 ] } , Series : series , Title : ChartTitle { Name : "Line chart with log 2 scaling" } , YAxis : ChartAxis { LogBase : 2 } } } ,
{ cell : "K25" , opts : & Chart { Type : Line , Dimension : ChartDimension { Width : dimension [ 2 ] , Height : dimension [ 3 ] } , Series : series , Title : ChartTitle { Name : "Line chart with log 1000.1 scaling" } , YAxis : ChartAxis { LogBase : 1000.1 } } } ,
{ cell : "P25" , opts : & Chart { Type : Line , Dimension : ChartDimension { Width : dimension [ 2 ] , Height : dimension [ 3 ] } , Series : series , Title : ChartTitle { Name : "Line chart with log 1000 scaling" } , YAxis : ChartAxis { LogBase : 1000 } } } ,
Breaking change: changed the function signature for 11 exported functions
* Change
`func (f *File) NewConditionalStyle(style string) (int, error)`
to
`func (f *File) NewConditionalStyle(style *Style) (int, error)`
* Change
`func (f *File) NewStyle(style interface{}) (int, error)`
to
`func (f *File) NewStyle(style *Style) (int, error)`
* Change
`func (f *File) AddChart(sheet, cell, opts string, combo ...string) error`
to
`func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddChartSheet(sheet, opts string, combo ...string) error`
to
`func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error`
* Change
`func (f *File) AddShape(sheet, cell, opts string) error`
to
`func (f *File) AddShape(sheet, cell string, opts *Shape) error`
* Change
`func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error`
to
`func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *PictureOptions) error`
* Change
`func (f *File) AddTable(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AddTable(sheet, reference string, opts *TableOptions) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error`
to
`func (f *File) AutoFilter(sheet, reference string, opts *AutoFilterOptions) error`
* Change
`func (f *File) SetPanes(sheet, panes string) error`
to
`func (f *File) SetPanes(sheet string, panes *Panes) error`
* Change
`func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error`
to
`func (sw *StreamWriter) AddTable(reference string, opts *TableOptions) error`
* Change
`func (f *File) SetConditionalFormat(sheet, reference, opts string) error`
to
`func (f *File) SetConditionalFormat(sheet, reference string, opts []ConditionalFormatOptions) error`
* Add exported types:
* AutoFilterListOptions
* AutoFilterOptions
* Chart
* ChartAxis
* ChartDimension
* ChartLegend
* ChartLine
* ChartMarker
* ChartPlotArea
* ChartSeries
* ChartTitle
* ConditionalFormatOptions
* PaneOptions
* Panes
* PictureOptions
* Shape
* ShapeColor
* ShapeLine
* ShapeParagraph
* TableOptions
* This added support for set sheet visible as very hidden
* Return error when missing required parameters for set defined name
* Update unit test and comments
2022-12-30 00:50:08 +08:00
} {
// Add two chart, one without and one with log scaling
assert . NoError ( t , f . AddChart ( sheet1 , c . cell , c . opts ) )
}
2020-07-11 01:07:41 +08:00
// Export XLSX file for human confirmation
2020-11-10 23:48:09 +08:00
assert . NoError ( t , f . SaveAs ( filepath . Join ( "test" , "TestChartWithLogarithmicBase10.xlsx" ) ) )
2020-07-11 01:07:41 +08:00
// Write the XLSX file to a buffer
var buffer bytes . Buffer
2020-11-10 23:48:09 +08:00
assert . NoError ( t , f . Write ( & buffer ) )
2020-07-11 01:07:41 +08:00
// Read back the XLSX file from the buffer
newFile , err := OpenReader ( & buffer )
assert . NoError ( t , err )
// Check the number of charts
expectedChartsCount := 6
chartsNum := newFile . countCharts ( )
if ! assert . Equal ( t , expectedChartsCount , chartsNum ,
"Expected %d charts, actual %d" , expectedChartsCount , chartsNum ) {
t . FailNow ( )
}
chartSpaces := make ( [ ] xlsxChartSpace , expectedChartsCount )
type xmlChartContent [ ] byte
xmlCharts := make ( [ ] xmlChartContent , expectedChartsCount )
expectedChartsLogBase := [ ] float64 { 0 , 10.5 , 0 , 2 , 0 , 1000 }
2021-07-05 00:03:56 +08:00
var (
drawingML interface { }
ok bool
)
2020-07-11 01:07:41 +08:00
for i := 0 ; i < expectedChartsCount ; i ++ {
chartPath := fmt . Sprintf ( "xl/charts/chart%d.xml" , i + 1 )
2021-07-05 00:03:56 +08:00
if drawingML , ok = newFile . Pkg . Load ( chartPath ) ; ok {
xmlCharts [ i ] = drawingML . ( [ ] byte )
}
2020-07-11 01:07:41 +08:00
assert . True ( t , ok , "Can't open the %s" , chartPath )
2022-03-24 00:19:30 +08:00
err = xml . Unmarshal ( xmlCharts [ i ] , & chartSpaces [ i ] )
2020-07-11 01:07:41 +08:00
if ! assert . NoError ( t , err ) {
t . FailNow ( )
}
chartLogBasePtr := chartSpaces [ i ] . Chart . PlotArea . ValAx [ 0 ] . Scaling . LogBase
if expectedChartsLogBase [ i ] == 0 {
if ! assert . Nil ( t , chartLogBasePtr , "LogBase is not nil" ) {
t . FailNow ( )
}
} else {
if ! assert . NotNil ( t , chartLogBasePtr , "LogBase is nil" ) {
t . FailNow ( )
}
if ! assert . Equal ( t , expectedChartsLogBase [ i ] , * ( chartLogBasePtr . Val ) ,
"Expected log base to %f, actual %f" , expectedChartsLogBase [ i ] , * ( chartLogBasePtr . Val ) ) {
t . FailNow ( )
}
}
}
}