At the moment only the XLSX and CSV formats are supported. It would be a good idea to add the TXT format as well.
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.
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
The UTF8 with BOM encoding should be used to properly preserve the different characters. Available in R3 2017 Official Release.
If row has a property set on it (for example "hidden" or a style), but it does not otherwise have any cells in it, the application might run into an infinite loop. The xml will look like this:
<sheetData>
<row r="1" spans="1:2" x14ac:dyDescent="0.35">
<c r="A1"><v>1</v></c>
<c r="B1"><v>2</v></c>
</row>
<row r="2" spans="1:2" s="1" customFormat="1" x14ac:dyDescent="0.35"/>
</sheetData>
The last row has formatting applied, so it is present as an element, but has no cells. This file (when the xml is not formatted) will cause an infinite loop on import.
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 }))); }
When calling SpreadExporter.CreateWorkbookExporter method and referencing Trial assemblies an exception is thrown: System.ArgumentException: 'An item with the same key has already been added.'
This behavior is observed both with the NuGet packages and DLLs.
It is not observed with Trial DLLs version 2020.3.1019
Add support for Data Validation.
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.
If you want to export a document with modified Normal style, you have to modify it and then set it to at least one cell in order to be exported. This maybe is caused by the fact that if the style is not used it is not exported. Workaround: Export single cell in the row with this style applied to it: using (ICellExporter cell = row.CreateCellExporter()) { cell.SetFormat(new SpreadCellFormat() { CellStyle = normalStyle }); }
Setting up a paper size to A1 and exporting the document actually sets the paperSize to 1.
This leads to inappropriate values when entering the Page Setup options later in Excel.