-
Notifications
You must be signed in to change notification settings - Fork 659
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
Uncaught TypeError: Cannot read property 'length' of undefined while exporting to Excel #1109
Comments
can anyone help me out in this |
Any chance you can create an example on jsfiddle that generates this error? |
Getting Same error :face_with_rolling_eyes: |
@artikhot97 Any chance you can create an example on jsfiddle that generates this error? |
Apply the patch file below and it works fine for me. diff --git a/node_modules/alasql/dist/alasql.fs.js b/node_modules/alasql/dist/alasql.fs.js
index 0129398..b7fb1e4 100644
--- a/node_modules/alasql/dist/alasql.fs.js
+++ b/node_modules/alasql/dist/alasql.fs.js
@@ -16739,10 +16739,14 @@ alasql.into.XLSX = function (filename, opts, data, columns, cb) {
var dataLength = Object.keys(data).length;
// Generate columns if they are not defined
- if ((!columns || columns.length == 0) && dataLength > 0) {
- columns = Object.keys(data[0]).map(function (columnid) {
- return {columnid: columnid};
- });
+ if ((!columns || columns.length == 0)) {
+ if (dataLength > 0) {
+ columns = Object.keys(data[0]).map(function (columnid) {
+ return {columnid: columnid};
+ });
+ } else {
+ columns = [];
+ }
}
var cells = {}; |
Amazing. Thank you! Would you like to edit the file and make a pull request so your name is tracked as a contributer, or are you ok with me just applying the patch? |
@mathiasrw |
While exporting the excel file i get the error saying "Uncaught TypeError: Cannot read property 'length' of undefined".
The scenario is : i have 6 different table which contains different data.When i am going to export it to excel sheet, it should create different 6 sheets in the Excel workbook.
When i have 1 empty table having no data, it creates an excel workbook with 1 empty sheet/tab but when i have more than 1 empty table, it fails to create an excel sheet and throws an error.
here is my query for the same.
var opts = [{sheetid:"Operations",header:true},{sheetid:"Operation Hooks",header:true},{sheetid:"Tool Groups",header:true},{sheetid:"BuyOffs",header:true},{sheetid:"Data Collection Groups",header:true},{sheetid:"DC Params",header:true}];
alasql('SELECT INTO XLSX(" ' + saveFile + '.xlsx", ?) FROM ?', [opts,[data,data1,data2,data3,data4,data5]]);
where data,data1,data2,data3,data4,data5 are the the data model(array) having the table data.
can someone please look into this. it needs to resolve in an urgency.
The text was updated successfully, but these errors were encountered: