-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export of simple json to xlsx file causes error in EXCEL #2720
Comments
You gave everything except for the part causing problems :/ The error message suggests that the worksheet name may be causing issues. What is To be sure this is not a normal occurrence, here's an example using your exact data: https://jsfiddle.net/gb2hakmd/ const fileName = "issue2720.xlsx";
const data = [
{'series name': 'Compliance/Legal', x: '0.5', y: '0.5', value: '1'},
{'series name': 'People', x: '4.5', y: '3.5', value: '1'},
{'series name': 'Brexit', x: '0.5', y: '4.5', value: '1'},
{'series name': 'Business Plan', x: '0.5', y: '4.5', value: '2'}
];
let workSheet = XLSX.utils.json_to_sheet(data, {header: ['series name', 'x', 'y', 'value']});
let wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, workSheet, fileName);
XLSX.writeFile(wb, fileName, {bookType: 'xlsx'}); |
Hi, yes, no problem. Attached is the file and the fileName is: I tried exporting with a fileName of |
Hey there, I just had the same problem, but managed to find a fix. @SheetJSDev could validation of the sheet names be possible? |
That was added in 0.18.10. Discussion continued in #2722 |
When exporting a simple JSON to xlsx, EXCEL throws the following error and claims to need to repair file.
On repairing the file, EXCEL report the following error in its log
<repairedRecord>Repaired Records: Worksheet properties from /xl/workbook.xml part (Workbook)</repairedRecord>
The JSON file exported is a very simple test file - see below
[
{series name: 'Compliance/Legal', x: '0.5', y: '0.5', value: '1'},
{series name: 'People', x: '4.5', y: '3.5', value: '1'},
{series name: 'Brexit', x: '0.5', y: '4.5', value: '1'},
{series name: 'Business Plan', x: '0.5', y: '4.5', value: '2'}
]
code used to create the file is as follows:
let workSheet = $XLSX.utils.json_to_sheet(data, {header: ['series name', 'x', 'y', 'value']});
let wb = $XLSX.utils.book_new();
$XLSX.utils.book_append_sheet(wb, workSheet, fileName);
$XLSX.writeFile(wb, fileName, {bookType: 'xlsx'});
Please advise.
The text was updated successfully, but these errors were encountered: