XLSX.js is a JavaScript library for converting the data in base64 XLSX files into JavaScript objects - and back! Please note that this library is licensed under the Microsoft Office Extensible File License - a license NOT approved by the OSI. While this license is based off of the MS-PL, which is OSI-approved, there are significant differences.
We encounter some problems when generated XlsX files from JSON. Our files were treaten as "corrupted" by Excel.
The origin is the number detection, implemented with parseFloat (l133):
while (++j < k) {
cell = data[i][j]; val = cell.hasOwnProperty('value') ? cell.value : cell; t = ''; style = cell.formatCode !== 'General' ? cell.formatCode : '';
if (val && typeof val === 'string' && isNaN(parseFloat(val))) { // If value is string, and not string of just a number, place a sharedString reference instead of the value
sharedStrings[1]++; // Increment total count, unique count derived from sharedStrings[0].length
The problem is that '2012-04-15 14:00:00' is detected as a number, and obviously its not. And because it's not stored inside shared strings, Excel will complain.
Same problem with string '2 !'.
I'd rather propose to always treat JSON strings as string values. If people want to generate numerical cell, they will provide JSON numbers instead.
Hello, and thanks for this library.
We encounter some problems when generated XlsX files from JSON. Our files were treaten as "corrupted" by Excel.
The origin is the number detection, implemented with parseFloat (l133):
The problem is that '2012-04-15 14:00:00' is detected as a number, and obviously its not. And because it's not stored inside shared strings, Excel will complain.
Same problem with string '2 !'.
I'd rather propose to always treat JSON strings as string values. If people want to generate numerical cell, they will provide JSON numbers instead.