How to export 2 tables to Excel in same file but different sheets in react js?

Viewed 301

How to export 2 tables to Excel in same file but different sheets in react.js?

Table code:

<table id='table1'>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
</table>

// table2 :

<table id='table2'>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>  
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
</table>

Upon clicking on a button, I want them to be in different sheets on same Excel file. I want to show table with id table1 in sheet1 and other on sheet2 of excel file with name Report. I've already tried to export 1 table using react-csv and react-html-table-to-excel packages but I am unable to export multiple tables.

How can I do that?

0 Answers
Related