linways/table-to-excel

Cannot set property 'width' of undefined

lynx12345 opened this issue · 2 comments

Hi!

I'm implemted succesfully an app with table to excel export, with this approach:

TableToExcel.convert(document.getElementById("table_SP_HOME_VER_PARTE_LOGIS_227"));

in the attach file, that line works fine with table2.html, but when I want to implement a new table (table1.html) it fails with this error:

TableToExcel.convert(document.getElementById("table_SP_GRD_RENDICION_228"))
tableToExcel.js:2 Uncaught TypeError: Cannot set property 'width' of undefined
    at tableToExcel.js:2
    at Array.forEach (<anonymous>)
    at Object.parseDomToTable (tableToExcel.js:2)
    at Object.tableToSheet (tableToExcel.js:508)
    at Object.tableToBook (tableToExcel.js:508)
    at Object.convert (tableToExcel.js:508)
    at <anonymous>:1:14

I don't understand why...

thnks in advance!

examples.zip

This is because, you defined width for 7 columns (data-cols-width="20,20,15,20,15,15,15") , while your table only contains 4. Just update data-cols-width="20,20,15,20" then it will work.
refer #13 also.
I will add a fix for this too as @aswinsreenath in #10 .

OK! thnks...