ArgumentException with clarification similar to "'\u001f', hexadecimal value 0x1F, is an invalid character." is thrown when trying to export document containing characters which are not supported in XML document - such as some control characters like 0x00, 0x1F, 0x1B, etc.
Such characters are described in the XML specification here: https://www.w3.org/TR/xml/#charsets.
using (var stream = File.OpenWrite("sample.xlsx")) using (var workbook = SpreadExporter.CreateWorkbookExporter(SpreadDocumentFormat.Xlsx, stream)) using (var worksheet = workbook.CreateWorksheetExporter("My sheet")) using (var row = worksheet.CreateRowExporter()) using (var cell = row.CreateCellExporter()) { cell.SetValue(string.Format("Error Value: {0} ", Encoding.ASCII.GetString(new byte[] { 8 }))); }
In addition to the fast document generation, the SpreadStreamProcessing can be adapted to import documents significantly faster than SpreadProcessing.
When setting a date in a cell using SetValue(DateTime), the value should be converted to its numerical representation before adding it to the XML. However, it is currently written as a string. This causes issues when opening the generated file with Google Sheets - the dates are not visible in the file. A customer also reported that this is causing issues when the file is opened with MS Excel in specific cultures, but we were unable to reproduce that locally. Workaround: Convert the DateTime value to a number before setting it to the cell: cell.SetValue(DateTime.Now.Date.ToOADate());
At the moment only the XLSX and CSV formats are supported. It would be a good idea to add the TXT format as well.
Expose an option to overwrite a sheet if it already exists in the workbook.
Provide a way to measure text on different platforms so the user can pass the cell value and SpreadCellFormat and get the size of the text in pixels. This way we will be able to implement auto-fit to width functionality (AutoFitWidth), at least for the .NET Framework implementation. It will be able to measure the width of all cells in a column and set the value as column width in pixels.
Allow the customers to work with XLS documents.
Sheets can have Visible, Hidden and Very Hidden visibility. Add support for setting this property.
The UTF8 with BOM encoding should be used to properly preserve the different characters. Available in R3 2017 Official Release.
Add API for appending data to existing worksheets. This way data could be filled in template documents.
The customers should have the ability to change the symbol used as a delimiter and the symbol used as a quote for a CSV document.
When a cell value contains commas or new lines, they are not escaped on export to CSV and single value is exported as multiple values. Workaround: Escape the value manually. For example, use the following extension method to set string cell values: internal static class CellExporterExtensions { public static void SetValue(this ICellExporter cell, string value, SpreadDocumentFormat format) { if (format == SpreadDocumentFormat.Csv) { if (value.Contains(",")) { // escape all quotes with double quotes value = value.Replace("\"", "\"\""); } // enclose all values within quotes value = string.Format("\"{0}\"", value); } cell.SetValue(value); } } Available in LIB version: 2017.1.403
Add support for creating Tables and applying tables styles (predefined ones, similar to MS Excel, or custom).
Add support for adding images to the exported document.
Add support for Data Validation.
Add support for Comments.
When exporting double values no value type is set to the cell. When a string value is exported the cell value type is set to Text. After setting string value the valueType is set to Text and when setting again value to double the type remains the same. When exporting double values no value type is set to the cell. When a string value is exported the cell value type is set to Text. After setting string value the valueType is set to Text and when setting again value to double the type remains the same. Workaround: Just set the value once and do not change it.