v1.13.0
Features
-
Support for creating a row of header names using the source generator. The new
Spreadsheet.AddHeaderRowAsync
method takes the type created by the source generator as the first argument, and an optional style as the second argument. By default the header name for a property will be the property name. E.g. this property:public string Surname { get; }
will create the header name
"Surname"
. The header name can be customized by using theColumnHeader
attribute. If we want to have header name"Last name"
instead, we can decorate the property with the attribute like this:[ColumnHeader("Last name")] public string Surname { get; }
-
Support for customizing the order between columns when using the source generator. By default, the order is decided by the order of the properties in the class/struct. The order can now be customized by using the
ColumnOrder
attribute. E.g. for these properties:[ColumnOrder(3)] public string LastName { get; } [ColumnOrder(1)] public string FirstName { get; } [ColumnOrder(2)] public string? MiddleName { get; }
the column order would be:
FirstName
,MiddleName
,LastName
. -
Illegal control characters from strings will now be ignored when writing the resulting XLSX file. These are the characters from
\x00
to\x1f
(except CR, LF, and TAB). These control characters can otherwise make the XLSX file invalid.
Performance improvements
-
All
Spreadsheet.AddRowAsync
methods now have improved performance by choosing between different implementations of the cell writers internally based onSpreadCheetahOptions.WriteCellReferenceAttributes
. -
SpreadsheetUtility.GetColumnName
will no longer allocate when the result is a one-character column name. Cases with longer column names also have improved performance, especially when running on .NET 8 or later. -
The source generator should now have better performance as well, and the source generator pipeline is now cachable. This should lead to a smaller impact on compile time for projects that are using the source generator. Thanks to Andrew Lock for his excellent article series about source generators!