errors.go 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. var (
  29. // ErrStreamSetColWidth defined the error message on set column width in
  30. // stream writing mode.
  31. ErrStreamSetColWidth = errors.New("must call the SetColWidth function before the SetRow function")
  32. // ErrColumnNumber defined the error message on receive an invalid column
  33. // number.
  34. ErrColumnNumber = errors.New("column number exceeds maximum limit")
  35. // ErrColumnWidth defined the error message on receive an invalid column
  36. // width.
  37. ErrColumnWidth = errors.New("the width of the column must be smaller than or equal to 255 characters")
  38. // ErrOutlineLevel defined the error message on receive an invalid outline
  39. // level number.
  40. ErrOutlineLevel = errors.New("invalid outline level")
  41. // ErrCoordinates defined the error message on invalid coordinates tuples
  42. // length.
  43. ErrCoordinates = errors.New("coordinates length must be 4")
  44. // ErrExistsWorksheet defined the error message on given worksheet already
  45. // exists.
  46. ErrExistsWorksheet = errors.New("the same name worksheet already exists")
  47. // ErrTotalSheetHyperlinks defined the error message on hyperlinks count
  48. // overflow.
  49. ErrTotalSheetHyperlinks = errors.New("over maximum limit hyperlinks in a worksheet")
  50. // ErrInvalidFormula defined the error message on receive an invalid
  51. // formula.
  52. ErrInvalidFormula = errors.New("formula not valid")
  53. // ErrAddVBAProject defined the error message on add the VBA project in
  54. // the workbook.
  55. ErrAddVBAProject = errors.New("unsupported VBA project extension")
  56. // ErrToExcelTime defined the error message on receive a not UTC time.
  57. ErrToExcelTime = errors.New("only UTC time expected")
  58. // ErrMaxRowHeight defined the error message on receive an invalid row
  59. // height.
  60. ErrMaxRowHeight = errors.New("the height of the row must be smaller than or equal to 409 points")
  61. // ErrImgExt defined the error message on receive an unsupported image
  62. // extension.
  63. ErrImgExt = errors.New("unsupported image extension")
  64. // ErrMaxFileNameLength defined the error message on receive the file name
  65. // length overflow.
  66. ErrMaxFileNameLength = errors.New("file name length exceeds maximum limit")
  67. )