Workbook with multiple sheet exports empty file #1118

Closed
opened 2018-05-23 18:32:07 +00:00 by iahmedani · 1 comment
iahmedani commented 2018-05-23 18:32:07 +00:00 (Migrated from github.com)

Hi team, I'm trying to export multiple table, when i export it creates empty workbook with sheet names only.

`export

Company Contact Country
Alfreds Futterkiste Maria Anders Germany
Berglunds snabbköp Christina Berglund Sweden
Centro comercial Moctezuma Francisco Chang Mexico
Ernst Handel Roland Mendel Austria
Island Trading Helen Bennett UK
Königlich Essen Philip Cramer Germany
Laughing Bacchus Winecellars Yoshi Tannamuri Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy
North/South Simon Crowther UK
Paris spécialités Marie Bertrand France
Company Contact Country
Alfreds Futterkiste Maria Anders Germany
Berglunds snabbköp Christina Berglund Sweden
Centro comercial Moctezuma Francisco Chang Mexico
Ernst Handel Roland Mendel Austria
Island Trading Helen Bennett UK
Königlich Essen Philip Cramer Germany
Laughing Bacchus Winecellars Yoshi Tannamuri Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy
North/South Simon Crowther UK
Paris spécialités Marie Bertrand France
Company Contact Country
Alfreds Futterkiste Maria Anders Germany
Berglunds snabbköp Christina Berglund Sweden
Centro comercial Moctezuma Francisco Chang Mexico
Ernst Handel Roland Mendel Austria
Island Trading Helen Bennett UK
Königlich Essen Philip Cramer Germany
Laughing Bacchus Winecellars Yoshi Tannamuri Canada
Magazzini Alimentari Riuniti Giovanni Rovelli Italy
North/South Simon Crowther UK
Paris spécialités Marie Bertrand France
`

javascript;

`
`

linked scripts:

`

    <script type="text/javascript" src="https://unpkg.com/blob.js@1.0.1/Blob.js"></script>
    <script type="text/javascript" src="https://unpkg.com/file-saver@1.3.3/FileSaver.js"></script>`
Hi team, I'm trying to export multiple table, when i export it creates empty workbook with sheet names only. `<button onclick="doit()">export</button> <table class="customers" id="t1"> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>Alfreds Futterkiste</td> <td>Maria Anders</td> <td>Germany</td> </tr> <tr> <td>Berglunds snabbköp</td> <td>Christina Berglund</td> <td>Sweden</td> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> <tr> <td>Ernst Handel</td> <td>Roland Mendel</td> <td>Austria</td> </tr> <tr> <td>Island Trading</td> <td>Helen Bennett</td> <td>UK</td> </tr> <tr> <td>Königlich Essen</td> <td>Philip Cramer</td> <td>Germany</td> </tr> <tr> <td>Laughing Bacchus Winecellars</td> <td>Yoshi Tannamuri</td> <td>Canada</td> </tr> <tr> <td>Magazzini Alimentari Riuniti</td> <td>Giovanni Rovelli</td> <td>Italy</td> </tr> <tr> <td>North/South</td> <td>Simon Crowther</td> <td>UK</td> </tr> <tr> <td>Paris spécialités</td> <td>Marie Bertrand</td> <td>France</td> </tr> </table> <table class="customers" id="t2"> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>Alfreds Futterkiste</td> <td>Maria Anders</td> <td>Germany</td> </tr> <tr> <td>Berglunds snabbköp</td> <td>Christina Berglund</td> <td>Sweden</td> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> <tr> <td>Ernst Handel</td> <td>Roland Mendel</td> <td>Austria</td> </tr> <tr> <td>Island Trading</td> <td>Helen Bennett</td> <td>UK</td> </tr> <tr> <td>Königlich Essen</td> <td>Philip Cramer</td> <td>Germany</td> </tr> <tr> <td>Laughing Bacchus Winecellars</td> <td>Yoshi Tannamuri</td> <td>Canada</td> </tr> <tr> <td>Magazzini Alimentari Riuniti</td> <td>Giovanni Rovelli</td> <td>Italy</td> </tr> <tr> <td>North/South</td> <td>Simon Crowther</td> <td>UK</td> </tr> <tr> <td>Paris spécialités</td> <td>Marie Bertrand</td> <td>France</td> </tr> </table> <table class="customers" id="t3"> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>Alfreds Futterkiste</td> <td>Maria Anders</td> <td>Germany</td> </tr> <tr> <td>Berglunds snabbköp</td> <td>Christina Berglund</td> <td>Sweden</td> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> <tr> <td>Ernst Handel</td> <td>Roland Mendel</td> <td>Austria</td> </tr> <tr> <td>Island Trading</td> <td>Helen Bennett</td> <td>UK</td> </tr> <tr> <td>Königlich Essen</td> <td>Philip Cramer</td> <td>Germany</td> </tr> <tr> <td>Laughing Bacchus Winecellars</td> <td>Yoshi Tannamuri</td> <td>Canada</td> </tr> <tr> <td>Magazzini Alimentari Riuniti</td> <td>Giovanni Rovelli</td> <td>Italy</td> </tr> <tr> <td>North/South</td> <td>Simon Crowther</td> <td>UK</td> </tr> <tr> <td>Paris spécialités</td> <td>Marie Bertrand</td> <td>France</td> </tr> </table>` javascript; `<script> function doit() { var t1 = document.getElementById('t1'); var t2 = document.getElementById('t2'); var t3 = document.getElementById('t3'); var workbook = XLSX.utils.book_new(); /* convert table 'table1' to worksheet named "Sheet1" */ var ws1 = XLSX.utils.table_to_book(t1); XLSX.utils.book_append_sheet(workbook, ws1, "Sheet1"); /* convert table 'table2' to worksheet named "Sheet2" */ var ws2 = XLSX.utils.table_to_book(t2); XLSX.utils.book_append_sheet(workbook, ws2, "Sheet2"); /* convert table 'table2' to worksheet named "Sheet3" */ var ws3 = XLSX.utils.table_to_book(t3); XLSX.utils.book_append_sheet(workbook, ws3, "Sheet3"); XLSX.writeFile(workbook, 'test.xlsx'); } </script> ` linked scripts: `<script type="text/javascript" src="https://unpkg.com/xlsx/dist/shim.min.js"></script> <script type="text/javascript" src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script> <script type="text/javascript" src="https://unpkg.com/blob.js@1.0.1/Blob.js"></script> <script type="text/javascript" src="https://unpkg.com/file-saver@1.3.3/FileSaver.js"></script>`
iahmedani commented 2018-05-23 18:43:34 +00:00 (Migrated from github.com)

found solution,
while defining sheet i'm using table_to_book instead of table_to_sheet,
erroneous example on readme.md file. need correction.

image

found solution, while defining sheet i'm using table_to_book instead of table_to_sheet, erroneous example on readme.md file. need correction. ![image](https://user-images.githubusercontent.com/17918895/40444512-ffbe219a-5ee2-11e8-90fe-7f714e4d9f98.png)
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#1118
No description provided.