19.19. v2.7.0

未匹配的标注

Excelize v2.7.0

版本说明

此版本中最显著的变化包括:

兼容性提示

  • 升级至该版本需要您使用的 Go 语言为 1.16 或更高版本,以迁移不再支持的标准库 ioutil
  • 当给定工作表名称中存在无效字符时将返回错误,不再自动忽略无效字符
  • GetCellStyle 函数不再返回合并单元格区域左上角单元格的样式
  • 重命名以下 5 个导出数据类型和错误常量:
    • PivotTableOption 重命名为 PivotTableOptions
    • FormatHeaderFooter 重命名为 HeaderFooterOptions
    • FormatSheetProtection 重命名为 SheetProtectionOptions
    • SparklineOption 重命名为 SparklineOptions
    • ErrExistsWorksheet 重命名为 ErrExistsSheet
  • 移除了以下 54 项导出类型:AutoPageBreaks, BaseColWidth, BlackAndWhite, CodeName, CustomHeight, Date1904, DefaultColWidth, DefaultGridColor, DefaultRowHeight, EnableFormatConditionsCalculation, FilterPrivacy, FirstPageNumber, FitToHeight, FitToPage, FitToWidth, OutlineSummaryBelow, PageLayoutOption, PageLayoutOptionPtr, PageLayoutOrientation, PageLayoutPaperSize, PageLayoutScale, PageMarginBottom, PageMarginFooter, PageMarginHeader, PageMarginLeft, PageMarginRight, PageMarginsOptions, PageMarginsOptionsPtr, PageMarginTop, Published, RightToLeft, SheetFormatPrOptions, SheetFormatPrOptionsPtr, SheetPrOption, SheetPrOptionPtr, SheetViewOption, SheetViewOptionPtr, ShowFormulas, ShowGridLines, ShowRowColHeaders, ShowRuler, ShowZeros, TabColorIndexed, TabColorRGB, TabColorTheme, TabColorTint, ThickBottom, ThickTop, TopLeftCell, View, WorkbookPrOption, WorkbookPrOptionPtr, ZeroHeightZoomScale
  • 移除了 2 个导出常量:OrientationPortraitOrientationLandscape
  • 修改了以下 21 个函数的签名
    • func (f *File) SetPageLayout(sheet string, opts ...PageLayoutOption) error 修改为 func (f *File) SetPageLayout(sheet string, opts *PageLayoutOptions) error
    • func (f *File) GetPageLayout(sheet string, opts ...PageLayoutOptionPtr) error 修改为 func (f *File) GetPageLayout(sheet string) (PageLayoutOptions, error)
    • func (f *File) SetPageMargins(sheet string, opts ...PageMarginsOptions) error 修改为 func (f *File) SetPageMargins(sheet string, opts *PageLayoutMarginsOptions) error
    • func (f *File) GetPageMargins(sheet string, opts ...PageMarginsOptionsPtr) error 修改为 func (f *File) GetPageMargins(sheet string) (PageLayoutMarginsOptions, error)
    • func (f *File) GetSheetIndex(sheet string) int 修改为 func (f *File) GetSheetIndex(sheet string) (int, error)
    • func (f *File) SetSheetName(source, target string) 修改为 func (f *File) SetSheetName(source, target string) error
    • func (f *File) GetSheetVisible(sheet string) 修改为 func (f *File) GetSheetVisible(sheet string) (bool, error)
    • func (f *File) DeleteSheet(sheet string) 修改为 func (f *File) DeleteSheet(sheet string) error
    • func (f *File) NewSheet(sheet string) int 修改为 func (f *File) NewSheet(sheet string) (int, error)
    • func (f *File) NewConditionalStyle(style string) (int, error) 修改为 func (f *File) NewConditionalStyle(style *Style) (int, error)
    • func (f *File) NewStyle(style interface{}) (int, error) 修改为 func (f *File) NewStyle(style *Style) (int, error)
    • func (f *File) AddChart(sheet, cell, opts string, combo ...string) error 修改为 func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error
    • func (f *File) AddChartSheet(sheet, opts string, combo ...string) error 修改为 func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error
    • func (f *File) AddShape(sheet, cell, opts string) error 修改为 func (f *File) AddShape(sheet, cell string, opts *Shape) error
    • func (f *File) AddPicture(sheet, cell, picture, format string) error 修改为 func (f *File) AddPicture(sheet, cell, picture string, opts *GraphicOptions) error
    • func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error 修改为 func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *GraphicOptions) error
    • func (f *File) AddTable(sheet, hCell, vCell, opts string) error 修改为 func (f *File) AddTable(sheet, rangeRef string, opts *TableOptions) error
    • func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error 修改为 func (sw *StreamWriter) AddTable(rangeRef string, opts *TableOptions) error
    • func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error 修改为 func (f *File) AutoFilter(sheet, rangeRef string, opts *AutoFilterOptions) error
    • func (f *File) SetPanes(sheet, panes string) error 修改为 func (f *File) SetPanes(sheet string, panes *Panes) error
    • func (f *File) SetConditionalFormat(sheet, reference, opts string) error 修改为 func (f *File) SetConditionalFormat(sheet, rangeRef string, opts []ConditionalFormatOptions) error
  • 引入新的函数代替现有函数:
    • 新增 SetSheetProps 代替 SetSheetPrOptionsSetSheetFormatPr 函数
    • 新增 GetSheetProps 代替 GetSheetPrOptionsGetSheetFormatPr 函数
    • 新增 SetSheetView 代替 SetSheetViewOptions 函数
    • 新增 GetSheetView 代替 GetSheetViewOptions 函数
    • 新增 SetWorkbookProps 代替 SetWorkbookPrOptions 函数
    • 新增 GetWorkbookProps 代替 GetWorkbookPrOptions 函数
    • 新增 InsertRows 代替 InsertRow 以支持批量添加行
    • 新增 InsertCols 代替 InsertCol 以支持批量添加列
  • CellType 枚举值中添加 CellTypeFormula, CellTypeInlineString, CellTypeSharedString 并移除了 CellTypeString
  • 对添加批注 AddComment 函数的签名进行了更改,支持创建富文本批注,相关 issue #1204
  • 当 XML 反序列化异常时将返回错误以代替输出日志,函数 GetComments, GetDefaultFontSetDefaultFont 增加了 error 类型的错误返回值

新增功能

  • 新增 GetDataValidationsGetConditionalFormats 函数以支持获取数据验证设置和条件格式,相关 issue #827
  • 新增 ProtectWorkbookUnprotectWorkbook 以提供工作簿保护设置支持
  • 新增 SetSheetCol 函数以支持按列设置单元格的值,相关 issue #1247
  • 新增 GetColStyle 函数以支持设置列样式,相关 issue #1293
  • 新增 SetSheetBackgroundFromBytes 函数以支持根据给定的图片数据设置工作表背景图片,相关 issue #1405
  • 新增导出变量 IndexedColorMapping 以支持内建索引颜色转换
  • 新增 20 项导出类型: AutoFilterListOptions, AutoFilterOptions, Chart, ChartAxis, ChartDimension, ChartLegend, ChartLine, ChartMarker, ChartPlotArea, ChartSeries, ChartTitle, ConditionalFormatOptions, PaneOptions, Panes, GraphicOptions, Shape, ShapeColor, ShapeLine, ShapeParagraphTableOptions
  • 新增 2 项公式函数: AGGREGATE 和 SUBTOTAL
  • SaveWriteWriteTo 函数支持指定保存选项,相关 issue #744
  • 使用 AddChart 函数添加图表时,支持为折线图设置是否使用平滑折线,相关 issue #1290
  • 使用 AddChart 函数添加图表时,支持设置自定义折线图线条颜色,相关 issue #1345
  • 使用 AddChart 函数添加图表时,支持设置自定义坐标轴字体样式,相关 issue #320
  • 添加图表函数 AddChart 支持创建三维折线图
  • 以下函数新增并发安全支持:SetColWidthGetColWidthSetColVisibleGetColVisibleSetColStyleGetColStyle
  • 设置样式时,当给定的样式 ID 不存在时将返回错误,相关 issue #1323
  • 流式按行赋值时,若行号未递增将返回错误,以避免生成的工作簿损坏,相关 issue #1139
  • 按行流式写入工作表时,支持通过指定 RowOpts 为单元格设置样式,相关 issue #1354
  • 支持流式设置窗格,相关 issue #1047
  • 支持流式设置行内富文本单元格
  • 支持流式插入分页符
  • 新增 7 项导出错误信息: ErrUnprotectWorkbookErrUnprotectWorkbookPasswordErrStreamSetPanesErrSheetNameBlankErrSheetNameInvalidErrSheetNameLengthErrSheetNameSingleQuote,以便开发者可根据不同的错误类型进行采取相应处理
  • 新增 5 项导出数据类型: HeaderFooterOptionsPageLayoutMarginsOptionsPageLayoutOptionsSheetPropsOptionsViewOptions
  • 支持设置分级显示的明细数据方向
  • 支持读取和设置单元格字体的主题颜色和色调,相关 issue #1369
  • 支持读取带有符合 ISO 8061 标准的时间类型单元格的值
  • 支持设置和读取带有内建颜色索引的字体颜色
  • 工作簿关闭函数将清理由流式写入器生成的磁盘缓存文件
  • 支持添加或删除列时自动调整受影响的列样式
  • 通过 AddPicture 添加图片时,现已允许插入 SVG 格式图片

兼容性提升

  • 流式写入单元格时将以行内字符类型存储字符型单元格的值,相关 issue #1377
  • 保存工作簿时将跳过工作表中的不带有样式和属性的空白行,以减少生成文档的体积,相关 issue #1383

问题修复

  • 修复部分情况下读取带有内建数字格式样式的浮点数精度有误问题,解决 issue #1328#1368#1373
  • 修复部分情况下读取带有 AM/PM 数字格式样式的单元格有误问题,解决 issue #1338
  • 修复部分情况下删除批注时由于数组下标越界导致的 panic,解决 issue #1343
  • 修复部分情况下读取单元格的值时出现 panic 的问题,解决 issue #1384#1415
  • 修复部分情况下误将文本解析为浮点型数值的问题,解决 issue #1360
  • 修复使用空字符创建工作表后生成的工作簿损坏问题,解决 issue #1361
  • 修复向工作表添加图片后,获取该图片内容为空的问题
  • 修复部分情况下插入行列后生成的工作簿损坏问题
  • 删除单元格公式时将删除公式计算链中的共享单元格引用,以修复部分情况下生成的文档损坏问题
  • 修复部分情况下未对工作表名称特殊字符及长度做正确处理的问题,解决 issue #1328
  • 修复部分情况下公式函数 OR 计算结果有误的问题
  • 修复在带有单一单元格区域引用的工作表中插入行列时,将收到异常的问题
  • 修复获取带有单一单元格区域引用合并单元格区域时,收到异常的问题
  • 修复部分情况下读取富文本单元格的值不完整问题
  • 修复流式写入时未转义 XML 字符导致的文档损坏问题,解决 issue #1391
  • 修复公式计算函数 ADDRESS 在工作表名称为空时计算结果有误的问题,解决 issue #1396
  • 修复部分情况下添加图片结果有误的问题,解决 issue #1404

性能优化

  • 提高流式合并单元格性能,相较于上一版本,耗时最高降低约 90%,内存使用最高减少约 86%
  • 优化按行流式写入工作表 SetRow 函数的性能,相较于上一版本,耗时最高降低约 19%

其他

  • Go Modules 依赖模块更新
  • 单元测试与文档更新
  • 优化内部变量与函数命名
  • 包含简体中文、英语、法语、俄语、日语、韩语、阿拉伯语、德语和西班牙语的多国语言文档网站更新

致谢

感谢 Excelize 的所有贡献者,以下是为此版本提交代码的贡献者列表:

  • @cdenicola (Cooper de Nicola)
  • @chenliu1993
  • @davidborry
  • @patsak (Kostya Privezentsev)
  • @dafengge0913
  • @Beeb0p (Artem Tarasenko)
  • @invzhi
  • @zhangzitao (Zitao)
  • @jtwatson (Joseph Watson)
  • @carbin-gun (charles.deng)
  • @harrison3000 (Harrison)
  • @strivek (GaoFei)
  • @gonghaibinx
  • @martinmr (Martin Martinez Rivera)
  • @zclark (Zach Clark)
  • @March0715 (March)
  • @renxiaotu
  • @devloppper
  • @jianxinhou
  • @nesstord
  • @Bayzet (Bayzet Tlyupov)
  • @guoweikuang (郭伟匡)
  • @qinyuguang (Gin)
  • @liron-l (Liron Levin)

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
xuri
讨论数量: 0
发起讨论 只看当前版本


暂无话题~