I'm generating an excel file with excel-builder.js like this:
require([
'./js/LibrariesForXLSX/excel-builder',
'./js/LibrariesForXLSX/Excel/Table'
], function(builder, Table) {
var book = builder.createWorkbook();
//creating worksheets
var userDataList = book.createWorksheet({
name: 'mysheet'
});
//creating tables
var userTable = new Table();
userTable.setReferenceRange([1, 1], [2, userData.length]);
//adding data and tables to sheets
userDataList.setData(userData);
userDataList.addTable(userTable);
//adding worksheets to workbook
book.addWorksheet(userDataList);
//adding tables to workbook
boook.addTable(userTable);
//creating download data;
var workBook = builder.createFile(book);
var rawExcelData = "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," + workBook;
var blob = exp_getBlob(workBook, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
//downloading workbook
saveAs(blob, 'export.xlsx');
});
}
where userData
is a 2D javascript array like
['name', 'John Doe'
'age', 23
]
saveAs
is a function from fileSaver.js
Everything works fine and the file is also generated, but when i try to open the file with Microsoft Excel 2016
i get an error like:
We found a problem with some content in 'export.xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes.
If i click yes everything is fine and the correct data shows up in the excel. Can i somehow get rid of this error message?