errors.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright 2016 - 2021 The excelize Authors. All rights reserved. Use of
  2. // this source code is governed by a BSD-style license that can be found in
  3. // the LICENSE file.
  4. //
  5. // Package excelize providing a set of functions that allow you to write to
  6. // and read from XLSX / XLSM / XLTM files. Supports reading and writing
  7. // spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports
  8. // complex components by high compatibility, and provided streaming API for
  9. // generating or reading data from a worksheet with huge amounts of data. This
  10. // library needs Go version 1.15 or later.
  11. package excelize
  12. import (
  13. "errors"
  14. "fmt"
  15. )
  16. func newInvalidColumnNameError(col string) error {
  17. return fmt.Errorf("invalid column name %q", col)
  18. }
  19. func newInvalidRowNumberError(row int) error {
  20. return fmt.Errorf("invalid row number %d", row)
  21. }
  22. func newInvalidCellNameError(cell string) error {
  23. return fmt.Errorf("invalid cell name %q", cell)
  24. }
  25. func newInvalidExcelDateError(dateValue float64) error {
  26. return fmt.Errorf("invalid date value %f, negative values are not supported supported", dateValue)
  27. }
  28. func newUnsupportChartType(chartType string) error {
  29. return fmt.Errorf("unsupported chart type %s", chartType)
  30. }
  31. var (
  32. // ErrStreamSetColWidth defined the error message on set column width in
  33. // stream writing mode.
  34. ErrStreamSetColWidth = errors.New("must call the SetColWidth function before the SetRow function")
  35. // ErrColumnNumber defined the error message on receive an invalid column
  36. // number.
  37. ErrColumnNumber = errors.New("column number exceeds maximum limit")
  38. // ErrColumnWidth defined the error message on receive an invalid column
  39. // width.
  40. ErrColumnWidth = fmt.Errorf("the width of the column must be smaller than or equal to %d characters", MaxColumnWidth)
  41. // ErrOutlineLevel defined the error message on receive an invalid outline
  42. // level number.
  43. ErrOutlineLevel = errors.New("invalid outline level")
  44. // ErrCoordinates defined the error message on invalid coordinates tuples
  45. // length.
  46. ErrCoordinates = errors.New("coordinates length must be 4")
  47. // ErrExistsWorksheet defined the error message on given worksheet already
  48. // exists.
  49. ErrExistsWorksheet = errors.New("the same name worksheet already exists")
  50. // ErrTotalSheetHyperlinks defined the error message on hyperlinks count
  51. // overflow.
  52. ErrTotalSheetHyperlinks = errors.New("over maximum limit hyperlinks in a worksheet")
  53. // ErrInvalidFormula defined the error message on receive an invalid
  54. // formula.
  55. ErrInvalidFormula = errors.New("formula not valid")
  56. // ErrAddVBAProject defined the error message on add the VBA project in
  57. // the workbook.
  58. ErrAddVBAProject = errors.New("unsupported VBA project extension")
  59. // ErrToExcelTime defined the error message on receive a not UTC time.
  60. ErrToExcelTime = errors.New("only UTC time expected")
  61. // ErrMaxRowHeight defined the error message on receive an invalid row
  62. // height.
  63. ErrMaxRowHeight = errors.New("the height of the row must be smaller than or equal to 409 points")
  64. // ErrImgExt defined the error message on receive an unsupported image
  65. // extension.
  66. ErrImgExt = errors.New("unsupported image extension")
  67. // ErrMaxFileNameLength defined the error message on receive the file name
  68. // length overflow.
  69. ErrMaxFileNameLength = errors.New("file name length exceeds maximum limit")
  70. // ErrEncrypt defined the error message on encryption spreadsheet.
  71. ErrEncrypt = errors.New("not support encryption currently")
  72. // ErrUnknownEncryptMechanism defined the error message on unsupport
  73. // encryption mechanism.
  74. ErrUnknownEncryptMechanism = errors.New("unknown encryption mechanism")
  75. // ErrUnsupportEncryptMechanism defined the error message on unsupport
  76. // encryption mechanism.
  77. ErrUnsupportEncryptMechanism = errors.New("unsupport encryption mechanism")
  78. // ErrParameterRequired defined the error message on receive the empty
  79. // parameter.
  80. ErrParameterRequired = errors.New("parameter is required")
  81. // ErrParameterInvalid defined the error message on receive the invalid
  82. // parameter.
  83. ErrParameterInvalid = errors.New("parameter is invalid")
  84. // ErrDefinedNameScope defined the error message on not found defined name
  85. // in the given scope.
  86. ErrDefinedNameScope = errors.New("no defined name on the scope")
  87. // ErrDefinedNameduplicate defined the error message on the same name
  88. // already exists on the scope.
  89. ErrDefinedNameduplicate = errors.New("the same name already exists on the scope")
  90. // ErrFontLength defined the error message on the length of the font
  91. // family name overflow.
  92. ErrFontLength = errors.New("the length of the font family name must be smaller than or equal to 31")
  93. // ErrFontSize defined the error message on the size of the font is invalid.
  94. ErrFontSize = errors.New("font size must be between 1 and 409 points")
  95. // ErrSheetIdx defined the error message on receive the invalid worksheet
  96. // index.
  97. ErrSheetIdx = errors.New("invalid worksheet index")
  98. // ErrGroupSheets defined the error message on group sheets.
  99. ErrGroupSheets = errors.New("group worksheet must contain an active worksheet")
  100. // ErrDataValidationFormulaLenth defined the error message for receiving a
  101. // data validation formula length that exceeds the limit.
  102. ErrDataValidationFormulaLenth = errors.New("data validation must be 0-255 characters")
  103. // ErrDataValidationRange defined the error message on set decimal range
  104. // exceeds limit.
  105. ErrDataValidationRange = errors.New("data validation range exceeds limit")
  106. // ErrCellCharsLength defined the error message for receiving a cell
  107. // characters length that exceeds the limit.
  108. ErrCellCharsLength = fmt.Errorf("cell value must be 0-%d characters", TotalCellChars)
  109. )