变量

  1. var (
  2. // ErrStreamSetColWidth 定义了在流式写入模式下设置列宽度时的错误提示信息
  3. ErrStreamSetColWidth = errors.New("must call the SetColWidth function before the SetRow function")
  4. // ErrStreamSetPanes 定义了在流式写入模式下设置窗格时的错误提示信息
  5. ErrStreamSetPanes = errors.New("must call the SetPanes function before the SetRow function")
  6. // ErrColumnNumber 定义了收到无效列名时的错误提示信息
  7. ErrColumnNumber = fmt.Errorf(`the column number must be greater than or equal to %d and less than or equal to %d`, MinColumns, MaxColumns)
  8. // ErrColumnWidth 定义了收到无效列宽度时的错误提示信息
  9. ErrColumnWidth = fmt.Errorf("the width of the column must be less than or equal to %d characters", MaxColumnWidth)
  10. // ErrOutlineLevel 定义了在数据分组时收到无效级别时的错误提示信息
  11. ErrOutlineLevel = errors.New("invalid outline level")
  12. // ErrCoordinates 定义了收到无效单元格坐标元组时的错误提示信息
  13. ErrCoordinates = errors.New("coordinates length must be 4")
  14. // ErrExistsSheet 定义了检测到已有相同名称工作表存在时的错误提示信息
  15. ErrExistsSheet = errors.New("the same name sheet already exists")
  16. // ErrTotalSheetHyperlinks 定义了工作表包含的超链接总数超出最大限制时的错误提示信息
  17. ErrTotalSheetHyperlinks = errors.New("over maximum limit hyperlinks in a worksheet")
  18. // ErrInvalidFormula 定义了收到无效公式时的错误提示信息
  19. ErrInvalidFormula = errors.New("formula not valid")
  20. // ErrAddVBAProject 定义了向工作簿嵌入 VBA 项目发生异常时的错误提示信息
  21. ErrAddVBAProject = errors.New("unsupported VBA project extension")
  22. // ErrMaxRows 定义了当行号超出最大限制时的错误提示信息
  23. ErrMaxRows = errors.New("row number exceeds maximum limit")
  24. // ErrMaxRowHeight 定义了收到无效行高度时的错误提示信息
  25. ErrMaxRowHeight = fmt.Errorf("the height of the row must be less than or equal to %d points", MaxRowHeight)
  26. // ErrImgExt 定义了不受支持的图片扩展名的错误提示信息
  27. ErrImgExt = errors.New("unsupported image extension")
  28. // ErrWorkbookFileFormat 定义了不受支持的工作簿文件类型的错误提示信息
  29. ErrWorkbookFileFormat = errors.New("unsupported workbook file format")
  30. // ErrMaxFilePathLength 定义了工作簿保存路径长度超出最大限制时的错误提示信息
  31. ErrMaxFilePathLength = fmt.Errorf("file path length exceeds maximum limit %d characters", MaxFilePathLength)
  32. // ErrUnknownEncryptMechanism 定义了检测到未知加密机制时的错误提示信息
  33. ErrUnknownEncryptMechanism = errors.New("unknown encryption mechanism")
  34. // ErrUnsupportedEncryptMechanism 定义了检测到不受支持的加密机制时的错误提示信息
  35. ErrUnsupportedEncryptMechanism = errors.New("unsupported encryption mechanism")
  36. // ErrUnsupportedHashAlgorithm 定义了检测到不受支持的哈希算法时的错误提示信息
  37. ErrUnsupportedHashAlgorithm = errors.New("unsupported hash algorithm")
  38. // ErrUnsupportedNumberFormat 定义了检测到不受支持的数字格式时的错误提示信息
  39. ErrUnsupportedNumberFormat = errors.New("unsupported number format token")
  40. // ErrPasswordLengthInvalid 定义了密码长度超出限制时的错误提示信息
  41. ErrPasswordLengthInvalid = errors.New("password length invalid")
  42. // ErrParameterRequired 定义了必要参数为空时的错误提示信息
  43. ErrParameterRequired = errors.New("parameter is required")
  44. // ErrParameterInvalid 定义了收到无效参数时的错误提示信息
  45. ErrParameterInvalid = errors.New("parameter is invalid")
  46. // ErrDefinedNameScope 定义了在给定范围内找不到指定名称时的错误提示信息
  47. ErrDefinedNameScope = errors.New("no defined name on the scope")
  48. // ErrDefinedNameDuplicate 定义了在给定范围内已经存在相同指定名称时的错误提示信息
  49. ErrDefinedNameDuplicate = errors.New("the same name already exists on the scope")
  50. // ErrCustomNumFmt 定义了指定自定义数字格式表达式为空时的错误提示信息
  51. ErrCustomNumFmt = errors.New("custom number format can not be empty")
  52. // ErrFontLength 定义了字体名称长度超出最大限制时的错误提示信息
  53. ErrFontLength = fmt.Errorf("the length of the font family name must be less than or equal to %d", MaxFontFamilyLength)
  54. // ErrFontSize 定义了收到无效字号时的错误提示信息
  55. ErrFontSize = fmt.Errorf("font size must be between %d and %d points", MinFontSize, MaxFontSize)
  56. // ErrSheetIdx 定义了收到了无效工作表索引时的错误提示信息
  57. ErrSheetIdx = errors.New("invalid worksheet index")
  58. // ErrUnprotectSheet 定义了取消保护工作表时的错误提示信息
  59. ErrUnprotectSheet = errors.New("worksheet has set no protect")
  60. // ErrUnprotectSheetPassword 定义了通过密码验证取消保护工作表失败时的错误提示信息
  61. ErrUnprotectSheetPassword = errors.New("worksheet protect password not match")
  62. // ErrGroupSheets 定义了工作表分组异常时的错误提示信息
  63. ErrGroupSheets = errors.New("group worksheet must contain an active worksheet")
  64. // ErrDataValidationFormulaLength 定义了数据验证公式长度超出最大限制时错误提示信息
  65. ErrDataValidationFormulaLength = fmt.Errorf("data validation must be 0-%d characters", MaxFieldLength)
  66. // ErrDataValidationRange 定义了指定数据验证小数范围无效时的错误提示信息
  67. ErrDataValidationRange = errors.New("data validation range exceeds limit")
  68. // ErrCellCharsLength 定义了单个单元格字符长度超出最大限制时的错误提示信息
  69. ErrCellCharsLength = fmt.Errorf("cell value must be 0-%d characters", TotalCellChars)
  70. // ErrOptionsUnzipSizeLimit
  71. // 定义了打开工作簿时,“用以指定打开电子表格文档时的解压缩大小限制参数”和
  72. // “用以指定解压每个工作表时的内存限制参数”产生冲突时的错误提示信息
  73. ErrOptionsUnzipSizeLimit = errors.New("the value of UnzipSizeLimit should be greater than or equal to UnzipXMLSizeLimit")
  74. // ErrSave 定义了保存工作簿时的错误提示信息
  75. ErrSave = errors.New("no path defined for file, consider File.WriteTo or File.Write")
  76. // ErrAttrValBool 定义了序列化或反序列化 XML 布尔类型值失败时的错误提示信息
  77. ErrAttrValBool = errors.New("unexpected child of attrValBool")
  78. // ErrSparklineType 定义了创建迷你图收到无效参数时的错误提示信息
  79. ErrSparklineType = errors.New("parameter 'Type' must be 'line', 'column' or 'win_loss'")
  80. // ErrSparklineLocation 定义了创建迷你图参数缺少 Location 字段时的错误提示信息
  81. ErrSparklineLocation = errors.New("parameter 'Location' is required")
  82. // ErrSparklineRange 定义了创建迷你图参数缺少 Range 字段时的错误提示信息
  83. ErrSparklineRange = errors.New("parameter 'Range' is required")
  84. // ErrSparkline 定义了收到无效迷你图创建参数时的错误提示信息
  85. ErrSparkline = errors.New("must have the same number of 'Location' and 'Range' parameters")
  86. // ErrSparklineStyle 定义了收到无效迷你图创建样式参数时的错误提示信息
  87. ErrSparklineStyle = errors.New("parameter 'Style' must between 0-35")
  88. // ErrWorkbookPassword 定义了打开工作簿时密码验证失败的错误提示信息
  89. ErrWorkbookPassword = errors.New("the supplied open workbook password is not correct")
  90. // ErrSheetNameInvalid 定义了收到带有无效字符的工作表名称时的错误提示信息
  91. ErrSheetNameInvalid = errors.New("the sheet can not contain any of the characters :\\/?*[or]")
  92. // ErrSheetNameSingleQuote 定义了收到的工作表名称中,第一个或者最后一个字符是单引号时的错误提示信息
  93. ErrSheetNameSingleQuote = errors.New("the first or last character of the sheet name can not be a single quote")
  94. // ErrSheetNameBlank 定义了收到的工作表名称为空时的错误提示信息
  95. ErrSheetNameBlank = errors.New("the sheet name can not be blank")
  96. // ErrSheetNameLength 定义了工作表名称长度超出最大限制时的错误提示信息
  97. ErrSheetNameLength = fmt.Errorf("the sheet name length exceeds the %d characters limit", MaxSheetNameLength)
  98. // ErrNameLength 定义了自定义名称或表格名称长度超出最大限制时的错误提示信息
  99. ErrNameLength = fmt.Errorf("the name length exceeds the %d characters limit", MaxFieldLength)
  100. // ErrExistsTableName 定义了给定表格名称已存在时的错误提示信息
  101. ErrExistsTableName = errors.New("the same name table already exists")
  102. // ErrCellStyles 定义了单元格格式数量超出最大限制时的错误提示信息
  103. ErrCellStyles = fmt.Errorf("the cell styles exceeds the %d limit", MaxCellStyles)
  104. // ErrUnprotectWorkbook 定义了取消保护工作簿时的错误提示信息
  105. ErrUnprotectWorkbook = errors.New("workbook has set no protect")
  106. // ErrUnprotectWorkbookPassword 定义了通过密码验证取消保护工作簿失败时的错误提示信息
  107. ErrUnprotectWorkbookPassword = errors.New("workbook protect password not match")
  108. // ErrorFormControlValue 定义了表单控件滚动值超过有效范围时的错误提示信息
  109. ErrorFormControlValue = fmt.Errorf("scroll value must be between 0 and %d", MaxFormControlValue)
  110. )

下列变量定义了 XML 源关系和命名空间列表、相关前缀和引入它的模式:

  1. var (
  2. NameSpaceDocumentPropertiesVariantTypes = xml.Attr{Name: xml.Name{Local: "vt", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"}
  3. NameSpaceDrawing2016SVG = xml.Attr{Name: xml.Name{Local: "asvg", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2016/SVG/main"}
  4. NameSpaceDrawingML = xml.Attr{Name: xml.Name{Local: "a", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/main"}
  5. NameSpaceDrawingMLChart = xml.Attr{Name: xml.Name{Local: "c", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/chart"}
  6. NameSpaceDrawingMLSpreadSheet = xml.Attr{Name: xml.Name{Local: "xdr", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing"}
  7. NameSpaceMacExcel2008Main = xml.Attr{Name: xml.Name{Local: "mx", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/mac/excel/2008/main"}
  8. NameSpaceSpreadSheet = xml.Attr{Name: xml.Name{Local: "xmlns"}, Value: "http://schemas.openxmlformats.org/spreadsheetml/2006/main"}
  9. NameSpaceSpreadSheetExcel2006Main = xml.Attr{Name: xml.Name{Local: "xne", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/excel/2006/main"}
  10. NameSpaceSpreadSheetX14 = xml.Attr{Name: xml.Name{Local: "x14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"}
  11. NameSpaceSpreadSheetX15 = xml.Attr{Name: xml.Name{Local: "x15", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main"}
  12. SourceRelationship = xml.Attr{Name: xml.Name{Local: "r", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/officeDocument/2006/relationships"}
  13. SourceRelationshipChart20070802 = xml.Attr{Name: xml.Name{Local: "c14", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2007/8/2/chart"}
  14. SourceRelationshipChart2014 = xml.Attr{Name: xml.Name{Local: "c16", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2014/chart"}
  15. SourceRelationshipChart201506 = xml.Attr{Name: xml.Name{Local: "c16r2", Space: "xmlns"}, Value: "http://schemas.microsoft.com/office/drawing/2015/06/chart"}
  16. SourceRelationshipCompatibility = xml.Attr{Name: xml.Name{Local: "mc", Space: "xmlns"}, Value: "http://schemas.openxmlformats.org/markup-compatibility/2006"}
  17. )

下面的变量定义了索引颜色和 RGB 色值的映射关系。为保证向后兼容性,其中值为 0-7 与 8-15 的索引颜色是重复的。索引颜色的值范围是 0-65。

  1. var IndexedColorMapping = []string{
  2. "000000", "FFFFFF", "FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF",
  3. "000000", "FFFFFF", "FF0000", "00FF00", "0000FF", "FFFF00", "FF00FF", "00FFFF",
  4. "800000", "008000", "000080", "808000", "800080", "008080", "C0C0C0", "808080",
  5. "9999FF", "993366", "FFFFCC", "CCFFFF", "660066", "FF8080", "0066CC", "CCCCFF",
  6. "000080", "FF00FF", "FFFF00", "00FFFF", "800080", "800000", "008080", "0000FF",
  7. "00CCFF", "CCFFFF", "CCFFCC", "FFFF99", "99CCFF", "FF99CC", "CC99FF", "FFCC99",
  8. "3366FF", "33CCCC", "99CC00", "FFCC00", "FF9900", "FF6600", "666699", "969696",
  9. "003366", "339966", "003300", "333300", "993300", "993366", "333399", "333333",
  10. "000000", "FFFFFF",
  11. }