变量

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

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

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

下面的变量定义了索引颜色和 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. }