How to convert html table to excel with multiple sheet?

后端 未结 8 1839
清歌不尽
清歌不尽 2020-11-28 05:53

How can I convert multiple html tables to an excel sheet with multiple worksheets? Could you please help into this.

My example https://jsfiddle.net/kdkd/5p22gdag/

8条回答
  •  盖世英雄少女心
    2020-11-28 06:37

    @Butani Vijay

    I found one issue with your code. Though maybe you could argue maybe my source table is not strictly HTML compliant.
    Specifically my table is defined similar to

        
    Name E-Mail Last
    Login
    Suspended
    Joe User JUser@xyz.edu 2020-02-18T16:42:50Z false
    Totals:

    and because of the
    included in Last
    Login
    the XML parse indicates it expected a
    . But why ??? HTML doesnt really have a
    And because of this although XLS would open there was no data in the spreadsheet, nor were any worksheets defined

    But a suitable fix is to change in your javascript of

    dataValue = (dataValue)?dataValue:tables[i].rows[j].cells[k].innerHTML;
    

    to

    dataValue = (dataValue)?dataValue:tables[i].rows[j].cells[k].innerText;
    

提交回复
热议问题