Closed afarn closed 4 years ago
Reported on MS Teams
FYI - also had this issue reported from one of our French customers. We found that the Unicode BOM was missing from the CSV file. If we edited the CSV file in Notepad, then saved as Unicode (not UTF-8) then opened the file again in Excel, characters were displayed OK.
I do have a question if this is actually partly fixed since the example page at https://master-enterprise.demo.design.infor.com/components/datagrid/example-export-from-button.html shows some of these characters in the test. And i see that the excel export button works but the CSV file doesnt.
@tmcconechy yes it is the CSV one that doesn't work, which I believe is the default Export option on the data grid (in this example they are manually added export button options). The exportToExcel API method appears to work, but puts the XML wrapper around the data that then throws warnings in Excel when opened so, for our application, this is not acceptable.
Yeah cant seem to get around the warning unless we include a complete excel parser. Will look at the CSV issue soon. The warning is https://github.com/infor-design/enterprise/issues/2995 - we "want" to fix it but looking for time
@tmcconechy Just looked at the solution for this, and the code appears to be setting a Unicode BOM but then encoding the save file as charset=UTF-8. You might want to review this again as in our own CSV save, we had to convert the CSV data (which will be in a UTF-16 string) to a byte array with a BOM (FF FE) and then put that into the Blob to save as charset=UTF-16. This was the only way we could get Excel to recognise non-ANSI characters.
@sanx72 how does that translate to a change in the code? Do you have a recommendation? cc @deep7102
@sanx72 I tested with excel on mac and windows using different browsers and looks fine those all the chars on test-page below, do you having some other set of chars you see issue. Please tell info browser, operating system or excel version etc https://master-enterprise.demo.design.infor.com/components/datagrid/example-export-from-button.html
Have you tried this export with sep=; (i.e. for French or other countries where comma is used in numerics for decimal). That was where I hit a problem anyway, with anything other than sep=, Excel import failed with UTF-8 BOM, but OK with UTF-16 BOM.
sep=; "Product Id";"Product Name";"Quantity";"Price";"Status";"Extra";"Filtered" "2142201";"Compressor";"1";"500,00";"OK";"ç ñ ÄËÏÖÜ äëïöü";"true" "2241202";"Different Compressor";"2";"210,99";"";"àèìòù";"true" "2342203";"Compressor";"1";"120,99";"";"áéíóú";"" "2445204";"Another Compressor";"3";"2.345,00";"OK";"ية (مصر";"true" "2542205";"I Love Compressors";"4";"210,99";"OK";"'=HYPERLINK(""http://www.google.com"";""Please Click For More Info"")'";"" "2642205";"Air Compressors";"41";"120,99";"OK";"";"" "2642206";"Some Compressor";"41";"123,99";"OK";"";"true"
I tried with the sep=";" but it doesn't work.
For the separator ";" it works with this condition in excel.js (line 368) :
if (separator.firstLine && separator.char ! == ',' && separator.char ! == ';') {
csv.unshift ([sep = $ {separator.char}
]);
}
proposition : For Angular, I propose to change the declaration of the exportToCsv function (but it is not mandatory) as follows: exportToCsv(fileName: string, customDs: Object[], separator: string | {})
and for example we can call this function like: exportToCsv(‘toto’, undefined, { firstLine: false, char: ' ;' }) ;
This issue is now resolved. Thank you. :)
Export to CSV with special characters (é, à, ü, û, ...) does not generate them correctly.