You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added attribute ColumnWidth, which can be used to set fixed column widths when using the source generator. The column widths must be set when starting a worksheet, and a new overload of Spreadsheet.StartWorksheetAsync has been added for convenience. Here is an example:
// Alternative 1: Use the new overload of StartWorksheetAsync.// It takes the context type generated by the source generator as the second parameter.awaitspreadsheet.StartWorksheetAsync("Sheet",BookContext.Default.Book);varbook=newBook{Title="A Game of Thrones",Author="George R. R. Martin"};awaitspreadsheet.AddAsRowAsync(book,BookContext.Default.Book);
In case you need to use WorksheetOptions, you can instead create an instance with the column widths like this:
// Alternative 2: Create an instance of WorksheetOptions from the context type.// The WorksheetOptions instance will be created with the column widths from the class attributes.varoptions=BookContext.Default.Book.CreateWorksheetOptions();// Can now set additional options, for example frozen columns.options.FrozenColumns=1;awaitspreadsheet.StartWorksheetAsync("Sheet",options);varbook=newBook{Title="A Game of Thrones",Author="George R. R. Martin"};awaitspreadsheet.AddAsRowAsync(book,BookContext.Default.Book);
Added attribute CellValueTruncate, which can be used to truncate string values when using the source generator. Here is an example:
varloremIpsum=newLoremIpsum{Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit."};awaitspreadsheet.AddAsRowAsync(loremIpsum,LoremIpsumContext.Default.LoremIpsum);
In this example, the value in cell A1 will be Lorem ipsum dol (the 15 first characters). A string consisting of fewer characters than the truncate length will have its whole value written to the cell. Internally the implementation will use ReadOnlyMemory<char> to avoid additional string allocations when truncating strings.
Bug fixes
Fixed a compilation issue for UWP when using .NET Native (issue #58).
WorksheetOptions.Column(int columnNumber) will no longer allow a column number larger than 16384 (maximum in Excel). An exception will be thrown if attempting to use a larger number.
Performance improvements
Smaller loop performance improvements in the hot path when adding rows to a worksheet.