Commit Graph

64 Commits

Author SHA1 Message Date
Ed 02b84a906c
This closes #1820, converted styleFillVariants from slice to func (#1821) 2024-02-24 09:11:31 +08:00
327674413 4eb3486682
This closes #1783, support set conditional formatting with multiple cell ranges (#1787) 2024-01-21 00:05:28 +08:00
xuri 792656552b
This closes #1777, fix the GetStyle or GetConditionalStyle function to returns incorrect DecimalPlaces field value
- Update documentation for the NewStyle function
- Update unit tests
- Update dependencies Go module
- Update GitHub workflow dependencies package version
- Update copyright agreement statement
2024-01-09 20:56:20 +08:00
xuri f4e395137d
This closes #1770, fix incorrect multiple conditional formats rules priorities
- Rename variable name hCell to topLeftCell, and rename vCell to bottomRightCell
- Update the unit tests
2023-12-30 14:41:16 +08:00
xuri bb8e5dacd2
This closes #1769 and closes #1770, support multiple conditional formats rules
- Update the unit tests
2023-12-28 16:38:13 +08:00
Yang Li 5e247de805
Support set time period type conditional formatting (#1718) 2023-11-14 09:47:57 +08:00
xuri 2499bf6b5b
Support 5 new kinds of conditional formatting types
- New conditional formatting types: text, blanks, no blanks, errors, and no errors
- Support calculate formula with multiple dash arithmetic symbol
- Fix empty calculate result with numeric arguments in LEN, LOWER, PROPER, REPT, UPPER, and IF formula functions
- Uniform double quote in calculation unit tests
- Update unit tests
2023-11-13 00:16:29 +08:00
xuri c7acf4fafe
Support update data validations on inserting/deleting columns/rows 2023-11-11 00:04:05 +08:00
ByteFlyCoding e014a8bb23
Support update conditional formatting on inserting/deleting columns/rows (#1717)
Return error for unsupported conditional formatting rule types
2023-11-10 09:25:59 +08:00
xuri 4e936dafdd
This closes #1706 and closes #1708
- Add export ChartLineType enumeration to specify the chart line type
- Add new Border field in the Chart type to set the chart area border
- Add new Type field in the ChartLine type to set the line type
- Fix some format missing on get style definition
- Update the unit tests
2023-11-03 00:12:43 +08:00
xuri 05689d6ade
This closes #1694, using namespace prefix in workbook theme XML
- Improve compatibility with the viewer which doesn't support default theme part namespace
- ref #1690, support read background color style, and conditional format with default pattern type
- Update the unit tests
2023-10-20 00:04:31 +08:00
xuri b52db71d61
This closes #1690, new exported function `GetConditionalStyle`
- Support get the conditional format style definition
- Update the unit test
2023-10-17 08:52:34 +08:00
xuri 1c23dc3507
This sorted exported error constants by name and listed them in one place 2023-09-28 08:53:54 +08:00
xuri ae64bcaabe
This fixes #1643, fixes #1647 and fixes #1653
- Correction cell type when formatting date type cell value
- Add check for MID and MIDB formula functions num_chars arguments, prevent panic on specifying a negative number
- Ref #65, add support for 2 formula functions: SEARCH and SEARCHB
- Fix a v2.8.0 regression bug, error on set print area and print titles with built-in special defined name
- Add new exported function `GetPivotTables` for get pivot tables
- Add a new `Name` field in the `PivotTableOptions` to support specify pivot table name
- Using relative cell reference in the pivot table docs and unit tests
- Support adding slicer content type part internally
- Add new exported source relationship and namespace `NameSpaceSpreadSheetXR10`, `ContentTypeSlicer`, `ContentTypeSlicerCache`, and `SourceRelationshipSlicer`
- Add new exported extended URI `ExtURIPivotCacheDefinition`
- Fix formula argument wildcard match issues
- Update GitHub Actions configuration, test on Go 1.21.x with 1.21.1 and later
- Avoid corrupted workbooks generated by improving compatibility with internally indexed color styles
2023-09-08 00:21:38 +08:00
cnmlgbgithub db22452398
This closes #314, closes #1520 and closes #1521 (#1574)
- Add new function GetStyle support for get style definition
2023-08-24 23:51:07 +08:00
xuri c63ae6d262
This fixed #1610, support to create a conditional format with number format and protection 2023-08-17 11:34:28 +08:00
xuri 49234fb95e
Ref #1199, this support applies partial built-in language number format code
- Remove the `Lang` field in the `Style` data type
- Rename field name `ShortDateFmtCode` to `ShortDatePattern` in the `Options` data type
- Rename field name `LongDateFmtCode` to `LongDatePattern` in the `Options` data type
- Rename field name `LongTimeFmtCode` to `LongTimePattern` in the `Options` data type
- Apply built-in language number format code number when creating a new style
- Checking and returning error if the date and time pattern was invalid
- Add new `Options` field `CultureInfo` and new exported data type `CultureName`
- Add new culture name types enumeration for country code
- Update unit tests
- Move built-in number format code and currency number format code definition source code
- Remove the built-in language number format code mapping with Unicode values
- Fix incorrect number formatted result for date and time with 12 hours at AM
2023-05-11 09:08:38 +08:00
xuri 0d193c76ac
This closes #1492, fix data bar min/max value doesn't work 2023-03-14 00:58:20 +08:00
xuri 65a53b3ec6
Breaking changes: replace the type `ShapeParagraph` with `RichTextRun`
- This removes the `Color` field from the type `Shape`, and uses the `Fill` instead of it
- Remove sharp symbol from hex RGB color
- Update unit tests
2023-02-27 00:05:36 +08:00
xuri 94e86dca31
This renamed conditional format type `iconSet` to `icon_set`
- Remove Minimum, Maximum, MinLength, and MaxLength fields from the type `ConditionalFormatOptions`
- Update unit tests and format code
2023-02-22 22:46:36 +08:00
xuri 753969dc4e
Support creating a conditional format with an "icon sets" rule
- Improvement compatibility for the worksheet extension lists
- Update unit test
2023-02-08 00:03:45 +08:00
xuri 3e2406096f
This closes #1462 and closes #1464
- Support creating a conditional format with a "stop if true" rule
- Support set border color and create solid color for the color data bar
- Fix incorrect cell type when modifying string cell with the time number
- Update unit test for the add pivot table to avoid pivot table range overlap
2023-02-07 00:08:11 +08:00
xuri 12645e7116
This fixes #1461, supports 0 row height and column width
- Increase max cell styles to 65430
- Add new exported error variable `ErrCellStyles`
- Update unit tests, support test under Go 1.20.x
2023-02-03 00:08:46 +08:00
xuri 85e0b6c56e
Support to create of 17 kinds of fill variants styles
- Update the unit tests
- Update the `SetHeaderFooter` function parameters name
- Update document for the `SetDocProps` and `SetCellHyperLink` functions
2023-02-01 00:11:08 +08:00
xuri b39626fae9
This fixed worksheet protection issue
- Update example code in the documentation
- Update unit tests
- Rename `PictureOptions` to `GraphicOptions`
- Adjust partial options fields data types for the `PictureOptions` and `Shape` structure
- Update dependencies module
2023-01-02 11:47:31 +08:00
xuri f58dabd492
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
郭伟匡 6a5ee811ba
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
xuri ac564afa56
Remove internal error log print, throw XML deserialize error 2022-11-13 00:40:04 +08:00
xuri bd5dd17673
This is a breaking change, remove partial internal error log print, throw XML deserialize error
- Add error return value for the `GetComments`, `GetDefaultFont` and `SetDefaultFont` functions
- Update unit tests
2022-11-12 00:16:23 +08:00
xuri a410b22bdd
Fix the error on getting the range of merged cells on the worksheet which contains one cell merged cell range
- Parse workbook default theme for custom theme color support in the feature
- Variables name typo fix
- Add system foreground and background color as RGB in the IndexedColorMapping list
2022-10-28 00:31:55 +08:00
xuri 53a495563a
This closes #1358, made a refactor with breaking changes, see details:
This made a refactor with breaking changes:

Motivation and Context

When I decided to add set horizontal centered support for this library to resolve #1358, the reason I made this huge breaking change was:

- There are too many exported types for set sheet view, properties, and format properties, although a function using the functional options pattern can be optimized by returning an anonymous function, these types or property set or get function has no binding categorization, so I change these functions like `SetAppProps` to accept a pointer of options structure.
- Users can not easily find out which properties should be in the `SetSheetPrOptions` or `SetSheetFormatPr` categories
- Nested properties cannot proceed modify easily

Introduce 5 new export data types:
`HeaderFooterOptions`, `PageLayoutMarginsOptions`, `PageLayoutOptions`, `SheetPropsOptions`, and `ViewOptions`

Rename 4 exported data types:
- Rename `PivotTableOption` to `PivotTableOptions`
- Rename `FormatHeaderFooter` to `HeaderFooterOptions`
- Rename `FormatSheetProtection` to `SheetProtectionOptions`
- Rename `SparklineOption` to `SparklineOptions`

Remove 54 exported types:
`AutoPageBreaks`, `BaseColWidth`, `BlackAndWhite`, `CodeName`, `CustomHeight`, `Date1904`, `DefaultColWidth`, `DefaultGridColor`, `DefaultRowHeight`, `EnableFormatConditionsCalculation`, `FilterPrivacy`, `FirstPageNumber`, `FitToHeight`, `FitToPage`, `FitToWidth`, `OutlineSummaryBelow`, `PageLayoutOption`, `PageLayoutOptionPtr`, `PageLayoutOrientation`, `PageLayoutPaperSize`, `PageLayoutScale`, `PageMarginBottom`, `PageMarginFooter`, `PageMarginHeader`, `PageMarginLeft`, `PageMarginRight`, `PageMarginsOptions`, `PageMarginsOptionsPtr`, `PageMarginTop`, `Published`, `RightToLeft`, `SheetFormatPrOptions`, `SheetFormatPrOptionsPtr`, `SheetPrOption`, `SheetPrOptionPtr`, `SheetViewOption`, `SheetViewOptionPtr`, `ShowFormulas`, `ShowGridLines`, `ShowRowColHeaders`, `ShowRuler`, `ShowZeros`, `TabColorIndexed`, `TabColorRGB`, `TabColorTheme`, `TabColorTint`, `ThickBottom`, `ThickTop`, `TopLeftCell`, `View`, `WorkbookPrOption`, `WorkbookPrOptionPtr`, `ZeroHeight` and `ZoomScale`

Remove 2 exported constants:
`OrientationPortrait` and `OrientationLandscape`

Change 8 functions:
- Change the `func (f *File) SetPageLayout(sheet string, opts ...PageLayoutOption) error` to `func (f *File) SetPageLayout(sheet string, opts *PageLayoutOptions) error`
- Change the `func (f *File) GetPageLayout(sheet string, opts ...PageLayoutOptionPtr) error` to `func (f *File) GetPageLayout(sheet string) (PageLayoutOptions, error)`
- Change the `func (f *File) SetPageMargins(sheet string, opts ...PageMarginsOptions) error` to `func (f *File) SetPageMargins(sheet string, opts *PageLayoutMarginsOptions) error`
- Change the `func (f *File) GetPageMargins(sheet string, opts ...PageMarginsOptionsPtr) error` to `func (f *File) GetPageMargins(sheet string) (PageLayoutMarginsOptions, error)`
- Change the `func (f *File) SetSheetViewOptions(sheet string, viewIndex int, opts ...SheetViewOption) error` to `func (f *File) SetSheetView(sheet string, viewIndex int, opts *ViewOptions) error`
- Change the `func (f *File) GetSheetViewOptions(sheet string, viewIndex int, opts ...SheetViewOptionPtr) error` to `func (f *File) GetSheetView(sheet string, viewIndex int) (ViewOptions, error)`
- Change the `func (f *File) SetWorkbookPrOptions(opts ...WorkbookPrOption) error` to `func (f *File) SetWorkbookProps(opts *WorkbookPropsOptions) error`
- Change the `func (f *File) GetWorkbookPrOptions(opts ...WorkbookPrOptionPtr) error` to `func (f *File) GetWorkbookProps() (WorkbookPropsOptions, error)`

Introduce new function to instead of existing functions:
- New function `func (f *File) SetSheetProps(sheet string, opts *SheetPropsOptions) error` instead of `func (f *File) SetSheetPrOptions(sheet string, opts ...SheetPrOption) error` and `func (f *File) SetSheetFormatPr(sheet string, opts ...SheetFormatPrOption
2022-09-29 22:04:50 +08:00
xuri 75ce231728
This closes #1323, an error will be returned when set the not exist style ID 2022-09-01 00:41:52 +08:00
davidborry bef49e40ee
This closes #1330 update non existing sheet error messages (#1331) 2022-08-28 00:16:41 +08:00
chenliu1993 f8667386dc
This closes #827, add new functions `GetDataValidations` and `GetConditionalFormats` (#1315)
Signed-off-by: chenliu1993 <13630583107@163.com>
2022-08-27 00:45:46 +08:00
xuri df91b34a3f
This closes #1211, improve the compatibility with invalid internal styles count 2022-04-28 15:33:25 +08:00
xuri 8a335225c7
Format code, update documentation and remove exported variable `XMLHeaderByte` 2022-03-24 00:19:30 +08:00
xuri 4b64b26c52
Ref: #660, #764, #1093, #1112, #1133 This improve number format support
- Introduced NFP (number format parser) dependencies module
- Initialize custom dates and times number format support
- Dependencies module upgraded
2022-02-13 00:06:30 +08:00
xuri 89b85934f6
This closes #1096, memory usage optimization and another 4 changes
- Unzip shared string table to system temporary file when large inner XML, reduce memory usage about 70%
- Remove unnecessary exported variable `XMLHeader`, we can using `encoding/xml` package's `xml.Header` instead of it
- Using constant instead of inline text for default XML path
- Rename exported option field `WorksheetUnzipMemLimit` to `UnzipXMLSizeLimit`
- Unit test and documentation updated
2021-12-27 23:49:28 +08:00
xuri 577a07f08c
Simplify code and update unit test
Improve unit test coverage for the functions: `NewStyle`, `SetActiveSheet`, `SearchSheet` and `deleteAndAdjustDefinedNames`
Simplify code and add comments for the function: `deleteAndAdjustDefinedNames`
2021-12-03 00:19:11 +08:00
Dokiy 45a1f08a2a Fix call getNumFmtID with builtInNumFmt return -1 2021-12-01 19:11:51 +08:00
xuri 9b0aa7ac30
This closes #1060, fix build-in time number format parse error 2021-11-20 11:31:17 +08:00
xuri bda8e7f812
This closes #1061, support multi-byte language on set header footer
typo fixed and simplify code for read the data values arguments of formula functions
2021-11-16 00:40:44 +08:00
xuri 2d8b5b1885
This closes #1027 and closes #1028
* Fix build-in scientific number format failed
* An error will be returned if given an invalid custom number format when creating a new style
2021-09-28 22:02:31 +08:00
xuri 544ef18a8c
- Support concurrency iterate rows and columns
- Rename exported field `File.XLSX` to `File.Pkg`
- Exported error message
2021-07-05 00:03:56 +08:00
ice c8c62c2d2a
* This closes #841, fix incorrect build number format in PR #839 2021-05-15 23:42:52 +08:00
xuri 2af96c0714
#65 fn: N, PERCENTILE.INC and T
typo fixed
2021-03-30 23:02:22 +08:00
xuri 2514bb16c6 Fix #724, standardize variable naming and update unit tests 2020-11-11 01:03:56 +08:00
xuri 9d470bb38f
Update conversion between integer types and unit tests 2020-10-23 00:01:52 +08:00
Artem Kustikov f2b8798a34
extend cell value load to support custom datetime format (#703)
* extend cell value load to support custom datetime format

* cleanup incorrect imports

* fix numeric values conversion as done in legacy Excel

* fix tests coverage

* revert temporary package name fix

* remove personal info from test XLSX files

* remove unused dependencies

* update format conversion in parseTime

* new UT to increase code coverage

* Resolve code review issue for PR #703

* Rename broken file name generated by unit test

Co-authored-by: xuri <xuri.me@gmail.com>
2020-10-04 21:07:39 +08:00
xuri 324f87bcae
add checking and limits for the worksheet 2020-09-18 22:20:58 +08:00