2023-01-02 11:47:31 +08:00
|
|
|
// Copyright 2016 - 2023 The excelize Authors. All rights reserved. Use of
|
2019-03-20 15:13:41 +08:00
|
|
|
// this source code is governed by a BSD-style license that can be found in
|
|
|
|
// the LICENSE file.
|
|
|
|
//
|
2022-02-17 00:09:11 +08:00
|
|
|
// Package excelize providing a set of functions that allow you to write to and
|
|
|
|
// read from XLAM / XLSM / XLSX / XLTM / XLTX files. Supports reading and
|
|
|
|
// writing spreadsheet documents generated by Microsoft Excel™ 2007 and later.
|
|
|
|
// Supports complex components by high compatibility, and provided streaming
|
|
|
|
// API for generating or reading data from a worksheet with huge amounts of
|
2023-01-02 11:47:31 +08:00
|
|
|
// data. This library needs Go version 1.16 or later.
|
2019-03-20 15:13:41 +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
|
|
|
package excelize
|
|
|
|
|
2021-05-10 00:09:24 +08:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
)
|
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
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newInvalidColumnNameError defined the error message on receiving the
|
|
|
|
// invalid column name.
|
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
|
|
|
func newInvalidColumnNameError(col string) error {
|
|
|
|
return fmt.Errorf("invalid column name %q", col)
|
|
|
|
}
|
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newInvalidRowNumberError defined the error message on receiving the invalid
|
|
|
|
// row number.
|
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
|
|
|
func newInvalidRowNumberError(row int) error {
|
|
|
|
return fmt.Errorf("invalid row number %d", row)
|
|
|
|
}
|
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newInvalidCellNameError defined the error message on receiving the invalid
|
|
|
|
// cell name.
|
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
|
|
|
func newInvalidCellNameError(cell string) error {
|
|
|
|
return fmt.Errorf("invalid cell name %q", cell)
|
|
|
|
}
|
2020-03-03 19:31:02 +08:00
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newInvalidExcelDateError defined the error message on receiving the data
|
|
|
|
// with negative values.
|
2020-03-03 19:31:02 +08:00
|
|
|
func newInvalidExcelDateError(dateValue float64) error {
|
2021-08-15 00:06:40 +08:00
|
|
|
return fmt.Errorf("invalid date value %f, negative values are not supported", dateValue)
|
2020-03-03 19:31:02 +08:00
|
|
|
}
|
2021-05-10 00:09:24 +08:00
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newUnsupportedChartType defined the error message on receiving the chart
|
|
|
|
// type are unsupported.
|
|
|
|
func newUnsupportedChartType(chartType string) error {
|
2021-07-05 00:03:56 +08:00
|
|
|
return fmt.Errorf("unsupported chart type %s", chartType)
|
|
|
|
}
|
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newUnzipSizeLimitError defined the error message on unzip size exceeds the
|
|
|
|
// limit.
|
2021-08-15 00:06:40 +08:00
|
|
|
func newUnzipSizeLimitError(unzipSizeLimit int64) error {
|
|
|
|
return fmt.Errorf("unzip size exceeds the %d bytes limit", unzipSizeLimit)
|
|
|
|
}
|
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newInvalidStyleID defined the error message on receiving the invalid style
|
|
|
|
// ID.
|
2021-08-17 00:01:44 +08:00
|
|
|
func newInvalidStyleID(styleID int) error {
|
2022-09-01 00:41:52 +08:00
|
|
|
return fmt.Errorf("invalid style ID %d", styleID)
|
2021-08-17 00:01:44 +08:00
|
|
|
}
|
|
|
|
|
2022-01-08 10:32:13 +08:00
|
|
|
// newFieldLengthError defined the error message on receiving the field length
|
|
|
|
// overflow.
|
2021-11-16 00:40:44 +08:00
|
|
|
func newFieldLengthError(name string) error {
|
2022-07-14 23:36:43 +08:00
|
|
|
return fmt.Errorf("field %s must be less than or equal to 255 characters", name)
|
2021-11-16 00:40:44 +08:00
|
|
|
}
|
|
|
|
|
2021-12-07 00:26:53 +08:00
|
|
|
// newCellNameToCoordinatesError defined the error message on converts
|
|
|
|
// alphanumeric cell name to coordinates.
|
|
|
|
func newCellNameToCoordinatesError(cell string, err error) error {
|
|
|
|
return fmt.Errorf("cannot convert cell %q to coordinates: %v", cell, err)
|
|
|
|
}
|
|
|
|
|
2022-08-28 00:16:41 +08:00
|
|
|
// newNoExistSheetError defined the error message on receiving the non existing
|
2022-08-19 23:24:13 +08:00
|
|
|
// sheet name.
|
|
|
|
func newNoExistSheetError(name string) error {
|
2022-08-28 00:16:41 +08:00
|
|
|
return fmt.Errorf("sheet %s does not exist", name)
|
2022-08-19 23:24:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// newNotWorksheetError defined the error message on receiving a sheet which
|
|
|
|
// not a worksheet.
|
|
|
|
func newNotWorksheetError(name string) error {
|
|
|
|
return fmt.Errorf("sheet %s is not a worksheet", name)
|
|
|
|
}
|
|
|
|
|
2022-10-20 00:02:30 +08:00
|
|
|
// newStreamSetRowError defined the error message on the stream writer
|
|
|
|
// receiving the non-ascending row number.
|
|
|
|
func newStreamSetRowError(row int) error {
|
|
|
|
return fmt.Errorf("row %d has already been written", row)
|
|
|
|
}
|
|
|
|
|
2022-10-28 00:31:55 +08:00
|
|
|
// newViewIdxError defined the error message on receiving a invalid sheet view
|
|
|
|
// index.
|
|
|
|
func newViewIdxError(viewIndex int) error {
|
|
|
|
return fmt.Errorf("view index %d out of range", viewIndex)
|
|
|
|
}
|
|
|
|
|
2021-05-10 00:09:24 +08:00
|
|
|
var (
|
|
|
|
// ErrStreamSetColWidth defined the error message on set column width in
|
|
|
|
// stream writing mode.
|
|
|
|
ErrStreamSetColWidth = errors.New("must call the SetColWidth function before the SetRow function")
|
2022-10-11 00:05:02 +08:00
|
|
|
// ErrStreamSetPanes defined the error message on set panes in stream
|
|
|
|
// writing mode.
|
|
|
|
ErrStreamSetPanes = errors.New("must call the SetPanes function before the SetRow function")
|
2021-05-10 00:09:24 +08:00
|
|
|
// ErrColumnNumber defined the error message on receive an invalid column
|
|
|
|
// number.
|
2022-07-14 23:36:43 +08:00
|
|
|
ErrColumnNumber = fmt.Errorf(`the column number must be greater than or equal to %d and less than or equal to %d`, MinColumns, MaxColumns)
|
2021-05-10 00:09:24 +08:00
|
|
|
// ErrColumnWidth defined the error message on receive an invalid column
|
|
|
|
// width.
|
2022-07-14 23:36:43 +08:00
|
|
|
ErrColumnWidth = fmt.Errorf("the width of the column must be less than or equal to %d characters", MaxColumnWidth)
|
2021-05-10 00:09:24 +08:00
|
|
|
// ErrOutlineLevel defined the error message on receive an invalid outline
|
|
|
|
// level number.
|
|
|
|
ErrOutlineLevel = errors.New("invalid outline level")
|
|
|
|
// ErrCoordinates defined the error message on invalid coordinates tuples
|
|
|
|
// length.
|
|
|
|
ErrCoordinates = errors.New("coordinates length must be 4")
|
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
|
|
|
// ErrExistsSheet defined the error message on given sheet already exists.
|
|
|
|
ErrExistsSheet = errors.New("the same name sheet already exists")
|
2021-05-10 00:09:24 +08:00
|
|
|
// ErrTotalSheetHyperlinks defined the error message on hyperlinks count
|
|
|
|
// overflow.
|
|
|
|
ErrTotalSheetHyperlinks = errors.New("over maximum limit hyperlinks in a worksheet")
|
|
|
|
// ErrInvalidFormula defined the error message on receive an invalid
|
|
|
|
// formula.
|
|
|
|
ErrInvalidFormula = errors.New("formula not valid")
|
|
|
|
// ErrAddVBAProject defined the error message on add the VBA project in
|
|
|
|
// the workbook.
|
|
|
|
ErrAddVBAProject = errors.New("unsupported VBA project extension")
|
2021-08-17 00:01:44 +08:00
|
|
|
// ErrMaxRows defined the error message on receive a row number exceeds maximum limit.
|
|
|
|
ErrMaxRows = errors.New("row number exceeds maximum limit")
|
2021-05-10 00:09:24 +08:00
|
|
|
// ErrMaxRowHeight defined the error message on receive an invalid row
|
|
|
|
// height.
|
2022-07-14 23:36:43 +08:00
|
|
|
ErrMaxRowHeight = fmt.Errorf("the height of the row must be less than or equal to %d points", MaxRowHeight)
|
2021-05-10 00:09:24 +08:00
|
|
|
// ErrImgExt defined the error message on receive an unsupported image
|
|
|
|
// extension.
|
|
|
|
ErrImgExt = errors.New("unsupported image extension")
|
2022-05-20 20:46:29 +08:00
|
|
|
// ErrWorkbookFileFormat defined the error message on receive an
|
|
|
|
// unsupported workbook file format.
|
|
|
|
ErrWorkbookFileFormat = errors.New("unsupported workbook file format")
|
2022-05-16 21:05:22 +08:00
|
|
|
// ErrMaxFilePathLength defined the error message on receive the file path
|
2021-05-10 00:09:24 +08:00
|
|
|
// length overflow.
|
2022-05-16 21:05:22 +08:00
|
|
|
ErrMaxFilePathLength = errors.New("file path length exceeds maximum limit")
|
2022-01-08 10:32:13 +08:00
|
|
|
// ErrUnknownEncryptMechanism defined the error message on unsupported
|
2021-07-05 00:03:56 +08:00
|
|
|
// encryption mechanism.
|
|
|
|
ErrUnknownEncryptMechanism = errors.New("unknown encryption mechanism")
|
2022-01-08 10:32:13 +08:00
|
|
|
// ErrUnsupportedEncryptMechanism defined the error message on unsupported
|
2021-07-05 00:03:56 +08:00
|
|
|
// encryption mechanism.
|
2022-01-08 10:32:13 +08:00
|
|
|
ErrUnsupportedEncryptMechanism = errors.New("unsupported encryption mechanism")
|
|
|
|
// ErrUnsupportedHashAlgorithm defined the error message on unsupported
|
|
|
|
// hash algorithm.
|
|
|
|
ErrUnsupportedHashAlgorithm = errors.New("unsupported hash algorithm")
|
2022-02-13 00:06:30 +08:00
|
|
|
// ErrUnsupportedNumberFormat defined the error message on unsupported number format
|
|
|
|
// expression.
|
|
|
|
ErrUnsupportedNumberFormat = errors.New("unsupported number format token")
|
2022-01-08 10:32:13 +08:00
|
|
|
// ErrPasswordLengthInvalid defined the error message on invalid password
|
|
|
|
// length.
|
|
|
|
ErrPasswordLengthInvalid = errors.New("password length invalid")
|
2021-07-05 00:03:56 +08:00
|
|
|
// ErrParameterRequired defined the error message on receive the empty
|
|
|
|
// parameter.
|
|
|
|
ErrParameterRequired = errors.New("parameter is required")
|
|
|
|
// ErrParameterInvalid defined the error message on receive the invalid
|
|
|
|
// parameter.
|
|
|
|
ErrParameterInvalid = errors.New("parameter is invalid")
|
|
|
|
// ErrDefinedNameScope defined the error message on not found defined name
|
|
|
|
// in the given scope.
|
|
|
|
ErrDefinedNameScope = errors.New("no defined name on the scope")
|
2022-03-24 00:19:30 +08:00
|
|
|
// ErrDefinedNameDuplicate defined the error message on the same name
|
2021-07-05 00:03:56 +08:00
|
|
|
// already exists on the scope.
|
2022-03-24 00:19:30 +08:00
|
|
|
ErrDefinedNameDuplicate = errors.New("the same name already exists on the scope")
|
2021-10-01 21:43:02 +08:00
|
|
|
// ErrCustomNumFmt defined the error message on receive the empty custom number format.
|
2021-09-28 22:02:31 +08:00
|
|
|
ErrCustomNumFmt = errors.New("custom number format can not be empty")
|
2021-07-05 00:03:56 +08:00
|
|
|
// ErrFontLength defined the error message on the length of the font
|
|
|
|
// family name overflow.
|
2022-07-14 23:36:43 +08:00
|
|
|
ErrFontLength = fmt.Errorf("the length of the font family name must be less than or equal to %d", MaxFontFamilyLength)
|
2021-07-05 00:03:56 +08:00
|
|
|
// ErrFontSize defined the error message on the size of the font is invalid.
|
2022-05-23 13:02:11 +08:00
|
|
|
ErrFontSize = fmt.Errorf("font size must be between %d and %d points", MinFontSize, MaxFontSize)
|
2021-07-05 00:03:56 +08:00
|
|
|
// ErrSheetIdx defined the error message on receive the invalid worksheet
|
|
|
|
// index.
|
|
|
|
ErrSheetIdx = errors.New("invalid worksheet index")
|
2022-01-08 10:32:13 +08:00
|
|
|
// ErrUnprotectSheet defined the error message on worksheet has set no
|
|
|
|
// protection.
|
|
|
|
ErrUnprotectSheet = errors.New("worksheet has set no protect")
|
|
|
|
// ErrUnprotectSheetPassword defined the error message on remove sheet
|
|
|
|
// protection with password verification failed.
|
|
|
|
ErrUnprotectSheetPassword = errors.New("worksheet protect password not match")
|
2021-07-05 00:03:56 +08:00
|
|
|
// ErrGroupSheets defined the error message on group sheets.
|
|
|
|
ErrGroupSheets = errors.New("group worksheet must contain an active worksheet")
|
2022-01-08 10:32:13 +08:00
|
|
|
// ErrDataValidationFormulaLength defined the error message for receiving a
|
2021-07-31 00:31:51 +08:00
|
|
|
// data validation formula length that exceeds the limit.
|
2022-05-23 13:02:11 +08:00
|
|
|
ErrDataValidationFormulaLength = fmt.Errorf("data validation must be 0-%d characters", MaxFieldLength)
|
2021-07-31 00:31:51 +08:00
|
|
|
// ErrDataValidationRange defined the error message on set decimal range
|
|
|
|
// exceeds limit.
|
|
|
|
ErrDataValidationRange = errors.New("data validation range exceeds limit")
|
2021-07-31 14:20:29 +08:00
|
|
|
// ErrCellCharsLength defined the error message for receiving a cell
|
|
|
|
// characters length that exceeds the limit.
|
|
|
|
ErrCellCharsLength = fmt.Errorf("cell value must be 0-%d characters", TotalCellChars)
|
2021-09-18 23:20:24 +08:00
|
|
|
// ErrOptionsUnzipSizeLimit defined the error message for receiving
|
2021-12-27 23:34:14 +08:00
|
|
|
// invalid UnzipSizeLimit and UnzipXMLSizeLimit.
|
|
|
|
ErrOptionsUnzipSizeLimit = errors.New("the value of UnzipSizeLimit should be greater than or equal to UnzipXMLSizeLimit")
|
2021-12-07 00:26:53 +08:00
|
|
|
// ErrSave defined the error message for saving file.
|
|
|
|
ErrSave = errors.New("no path defined for file, consider File.WriteTo or File.Write")
|
|
|
|
// ErrAttrValBool defined the error message on marshal and unmarshal
|
|
|
|
// boolean type XML attribute.
|
|
|
|
ErrAttrValBool = errors.New("unexpected child of attrValBool")
|
|
|
|
// ErrSparklineType defined the error message on receive the invalid
|
|
|
|
// sparkline Type parameters.
|
|
|
|
ErrSparklineType = errors.New("parameter 'Type' must be 'line', 'column' or 'win_loss'")
|
|
|
|
// ErrSparklineLocation defined the error message on missing Location
|
|
|
|
// parameters
|
|
|
|
ErrSparklineLocation = errors.New("parameter 'Location' is required")
|
|
|
|
// ErrSparklineRange defined the error message on missing sparkline Range
|
|
|
|
// parameters
|
|
|
|
ErrSparklineRange = errors.New("parameter 'Range' is required")
|
|
|
|
// ErrSparkline defined the error message on receive the invalid sparkline
|
|
|
|
// parameters.
|
|
|
|
ErrSparkline = errors.New("must have the same number of 'Location' and 'Range' parameters")
|
|
|
|
// ErrSparklineStyle defined the error message on receive the invalid
|
|
|
|
// sparkline Style parameters.
|
2022-01-08 10:32:13 +08:00
|
|
|
ErrSparklineStyle = errors.New("parameter 'Style' must between 0-35")
|
2022-05-20 20:46:29 +08:00
|
|
|
// ErrWorkbookPassword defined the error message on receiving the incorrect
|
|
|
|
// workbook password.
|
|
|
|
ErrWorkbookPassword = errors.New("the supplied open workbook password is not correct")
|
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
|
|
|
// ErrSheetNameInvalid defined the error message on receive the sheet name
|
|
|
|
// contains invalid characters.
|
|
|
|
ErrSheetNameInvalid = errors.New("the sheet can not contain any of the characters :\\/?*[or]")
|
|
|
|
// ErrSheetNameSingleQuote defined the error message on the first or last
|
|
|
|
// character of the sheet name was a single quote.
|
|
|
|
ErrSheetNameSingleQuote = errors.New("the first or last character of the sheet name can not be a single quote")
|
|
|
|
// ErrSheetNameBlank defined the error message on receive the blank sheet
|
|
|
|
// name.
|
|
|
|
ErrSheetNameBlank = errors.New("the sheet name can not be blank")
|
|
|
|
// ErrSheetNameLength defined the error message on receiving the sheet
|
|
|
|
// name length exceeds the limit.
|
|
|
|
ErrSheetNameLength = fmt.Errorf("the sheet name length exceeds the %d characters limit", MaxSheetNameLength)
|
2023-02-02 22:02:32 +08:00
|
|
|
// ErrCellStyles defined the error message on cell styles exceeds the limit.
|
|
|
|
ErrCellStyles = fmt.Errorf("the cell styles exceeds the %d limit", MaxCellStyles)
|
2022-12-27 00:06:18 +08:00
|
|
|
// ErrUnprotectWorkbook defined the error message on workbook has set no
|
|
|
|
// protection.
|
|
|
|
ErrUnprotectWorkbook = errors.New("workbook has set no protect")
|
|
|
|
// ErrUnprotectWorkbookPassword defined the error message on remove workbook
|
|
|
|
// protection with password verification failed.
|
|
|
|
ErrUnprotectWorkbookPassword = errors.New("workbook protect password not match")
|
2021-05-10 00:09:24 +08:00
|
|
|
)
|