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) bool 修改為 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)

results matching ""

    No results matching ""