gitea xuri/excelize v2.7.0

latest releases: v2.8.1, v2.8.0, v2.7.1...
22 months ago

We are pleased to announce the release of version 2.7.0. Featured are a handful of new areas of functionality and numerous bug fixes.

A summary of changes is available in the Release Notes. A full list of changes is available in the changelog.

Release Notes

The most notable changes in this release are:

Breaking Change

  • Upgrade requirements Go language version is 1.16 or later, for migration of deprecation package ioutil
  • Checking and return error for invalid sheet name instead of trim invalid characters
  • The GetCellStyle function no longer return master cell style of the merge cell range
  • Rename 5 exported data types and error constant:
    • Rename PivotTableOption to PivotTableOptions
    • Rename FormatHeaderFooter to HeaderFooterOptions
    • Rename FormatSheetProtection to SheetProtectionOptions
    • Rename SparklineOption to SparklineOptions
    • Rename ErrExistsWorksheet to ErrExistsSheet
  • Remove 54 exported types: 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, ZeroHeight and ZoomScale
  • Remove 2 exported constants: OrientationPortrait and OrientationLandscape
  • Change 21 functions signature:
    • Change the func (f *File) SetPageLayout(sheet string, opts ...PageLayoutOption) error to func (f *File) SetPageLayout(sheet string, opts *PageLayoutOptions) error
    • Change the func (f *File) GetPageLayout(sheet string, opts ...PageLayoutOptionPtr) error to func (f *File) GetPageLayout(sheet string) (PageLayoutOptions, error)
    • Change the func (f *File) SetPageMargins(sheet string, opts ...PageMarginsOptions) error to func (f *File) SetPageMargins(sheet string, opts *PageLayoutMarginsOptions) error
    • Change the func (f *File) GetPageMargins(sheet string, opts ...PageMarginsOptionsPtr) error to func (f *File) GetPageMargins(sheet string) (PageLayoutMarginsOptions, error)
    • Change the func (f *File) GetSheetIndex(sheet string) int to func (f *File) GetSheetIndex(sheet string) (int, error)
    • Change the func (f *File) SetSheetName(source, target string) to func (f *File) SetSheetName(source, target string) error
    • Change the func (f *File) GetSheetVisible(sheet string) to func (f *File) GetSheetVisible(sheet string) (bool, error)
    • Change the func (f *File) DeleteSheet(sheet string) to func (f *File) DeleteSheet(sheet string) error
    • Change the func (f *File) NewSheet(sheet string) int to func (f *File) NewSheet(sheet string) (int, error)
    • Change the func (f *File) NewConditionalStyle(style string) (int, error) to func (f *File) NewConditionalStyle(style *Style) (int, error)
    • Change the func (f *File) NewStyle(style interface{}) (int, error) to func (f *File) NewStyle(style *Style) (int, error)
    • Change the func (f *File) AddChart(sheet, cell, opts string, combo ...string) error to func (f *File) AddChart(sheet, cell string, chart *ChartOptions, combo ...*ChartOptions) error
    • Change the func (f *File) AddChartSheet(sheet, opts string, combo ...string) error to func (f *File) AddChartSheet(sheet string, chart *ChartOptions, combo ...*ChartOptions) error
    • Change the func (f *File) AddShape(sheet, cell, opts string) error to func (f *File) AddShape(sheet, cell string, opts *Shape) error
    • Change the func (f *File) AddPicture(sheet, cell, picture, format string) error to func (f *File) AddPicture(sheet, cell, picture string, opts *GraphicOptions) error
    • Change the func (f *File) AddPictureFromBytes(sheet, cell, opts, name, extension string, file []byte) error to func (f *File) AddPictureFromBytes(sheet, cell, name, extension string, file []byte, opts *GraphicOptions) error
    • Change the func (f *File) AddTable(sheet, hCell, vCell, opts string) error to func (f *File) AddTable(sheet, rangeRef string, opts *TableOptions) error
    • Change the func (sw *StreamWriter) AddTable(hCell, vCell, opts string) error to func (sw *StreamWriter) AddTable(rangeRef string, opts *TableOptions) error
    • Change the func (f *File) AutoFilter(sheet, hCell, vCell, opts string) error to func (f *File) AutoFilter(sheet, rangeRef string, opts *AutoFilterOptions) error
    • Change the func (f *File) SetPanes(sheet, panes string) error to func (f *File) SetPanes(sheet string, panes *Panes) error
    • Change the func (f *File) SetConditionalFormat(sheet, reference, opts string) error to func (f *File) SetConditionalFormat(sheet, rangeRef string, opts []ConditionalFormatOptions) error
  • Introduce new function to instead of existing functions:
    • Use SetSheetProps instead of SetSheetPrOptions and SetSheetFormatPr
    • Use GetSheetProps instead of GetSheetPrOptions and GetSheetFormatPr
    • Use SetSheetView instead of SetSheetViewOptions
    • Use GetSheetView instead of GetSheetViewOptions
    • Use SetWorkbookProps instead of SetWorkbookPrOptions
    • Use GetWorkbookProps instead of GetWorkbookPrOptions
    • Use InsertRows instead of InsertRow for support inserting multiple rows at once
    • Use InsertCols instead of InsertCol for support inserting multiple columns at once
  • Add CellTypeFormula, CellTypeInlineString, CellTypeSharedString and remove CellTypeString in CellType enumeration
  • The parameter has been changed for the AddComment function, support create rich-text in comments, related issue #1204
  • Remove internal error log print, an error will be returned when XML deserialize error, add error return value for the GetComments, GetDefaultFont and SetDefaultFont functions

Notable Features

  • Add new functions GetDataValidations and GetConditionalFormats for get data validations and conditional formats, related issue #827
  • Add new functions ProtectWorkbook and UnprotectWorkbook for workbook protection supports
  • Add new function SetSheetCol for set worksheet column cells, related issue #1247
  • Add new function GetColStyle for set column styles, related issue #1293
  • Add new function SetSheetBackgroundFromBytes for set background picture by given image data, related issue #1405
  • Add new export variable IndexedColorMapping
  • Add 20 export types: AutoFilterListOptions, AutoFilterOptions, Chart, ChartAxis, ChartDimension, ChartLegend, ChartLine, ChartMarker, ChartPlotArea, ChartSeries, ChartTitle, ConditionalFormatOptions, PaneOptions, Panes, GraphicOptions, Shape, ShapeColor, ShapeLine, ShapeParagraph and TableOptions
  • New support 2 formula functions: AGGREGATE and SUBTOTAL
  • The Save, Write and WriteTo function now accept saving options, related issue #744
  • The AddChart function support specify if smooth line of the line chart, related issue #1290
  • The AddChart function support set custom line color in the charts, related issue #1345
  • The AddChart function support custom chart axis font style, related issue #320
  • The AddChart function support create 3D line chart
  • The functions SetColWidth, GetColWidth, SetColVisible, GetColVisible, SetColStyle and GetColStyle now support concurrency safe
  • An error will be returned when set the not exist style ID, related issue #1323
  • An error will be returned when setting the stream row without ascending row numbers, to avoid potential mistakes, related issue #1139
  • The stream writer will be apply style in RowOpts for each cell, related issue #1354
  • The stream writer support to set panes, related issue #1047
  • The stream writer support to set inline rich text cell
  • The stream writer support to insert the page break
  • New 7 exported errors: ErrUnprotectWorkbook, ErrUnprotectWorkbookPassword, ErrStreamSetPanes, ErrSheetNameBlank, ErrSheetNameInvalid, ErrSheetNameLength and ErrSheetNameSingleQuote has been added
  • Introduce 5 new export data types: HeaderFooterOptions, PageLayoutMarginsOptions, PageLayoutOptions, SheetPropsOptions, and ViewOptions
  • Support to set summary columns to appear to the right of detail in an outline
  • Support to set and get font color with theme and tint, related issue #1369
  • Support get cell value which contains a date in the ISO 8601 format
  • Support set and get font color with indexed color
  • Support update column style when inserting or deleting columns
  • The workbook Close function now support cleanup stream writer temporary files
  • The AddPicture function now allowing insert SVG format images

Improve the Compatibility

  • Stream writer writes inline string type for string cell value, related issue #1377
  • Skip empty rows when saving the spreadsheet to reduce file size, related issue #1383

Bug Fixes

  • Fix decimal number format round issue with build-in number format, resolve issue #1328, #1368 and #1373
  • Fix apply AM/PM number format issue in some case, resolve issue #1338
  • Fix the panic when delete comments caused by slice bounds out of range, resolve issue #1343
  • Fix the panic when get cell value in some case, resolve issue #1384 and #1415
  • Fix default number format parse issue with a long string of digits, resolve issue #1360
  • Fix creating a sheet with an empty name cause a corrupted file, resolve issue #1361
  • Fix get image content was empty after inserting image
  • Fix generate workbook corruption after insert columns/rows in some case
  • Delete shared formula in calc chain when writing a formula cell, to fix generate workbook corruption in some case
  • Normalize the sheet name to fix behavior regression between 2.6.0 & 2.6.1, resolve issue #1365
  • Fix the formula calculation result issue of the OR function
  • Fix error on inserting columns or rows on the worksheet which contains one cell merged cell range
  • Fix error on getting the range of merged cells on the worksheet which contains one cell merged cell range
  • Fix getting incomplete rich text cell value in some cases
  • Escape XML characters for stream writer to avoid with corrupt file, resolve issue #1391
  • Fix formula function ADDRESS result error with empty worksheet name, resolve issue #1396
  • Fix insert picture problem in some cases, resolve issue #1404

Performance

  • Improve performance for stream writer merging cells, time cost decrease over 90% and reduce memory usage by about 86% at most
  • Improving performance for stream writer SetRow function, reduces memory usage over and speedup about 19%

Miscellaneous

  • The dependencies module has been updated
  • Unit tests and godoc updated
  • Using the specialized name in variables and functions
  • Documentation website with multilingual: Arabic, German, Spanish, English, French, Russian, Chinese, Japanese, and Korean, which has been updated

Thank you

Thanks for all the contributors to Excelize. Below is a list of contributors that have code contributions in this version:

  • @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)

Don't miss a new excelize release

NewReleases is sending notifications on new releases.