Solution 1 :

Note: Without knowing your approach because the implementation hasn’t been started at your end as mentioned in the comments in your question, it is hard to understand your code structure. This example only exports one table, but you should be able to dig through the libraries documentation to find out the possible ways to merge different tables in single file. Just search for multiple sheet in single file with sheet js or check this SO answer. Implement your logic and if run into issues, update the question with the problem.

You can make use of the available javascript libraries to generate xlsx file.
You will need to add following scripts on the page. The only drawback with this approach is 4 external libraries, so only load them on a page you need.

<script src=""></script>
<script src=""></script>
<script src="[email protected]/Blob.js"></script>
<script src="[email protected]/FileSaver.js"></script>

Create a table with your data

  <table id="tableToExport">
      <td>John Doe</td>
      <td>[email protected]</td>
      <td>Jane Doe</td>
      <td>[email protected]</td>

Add event listener on a button or any element to trigger export.

var btn = document.getElementById("createXLSX");
var fileName = "test";
var fileType = "xlsx";
btn.addEventListener("click", function() {
   var table = document.getElementById("tableToExport");
   var wb = XLSX.utils.table_to_book(table, {sheet: "Sheet JS"});
   return XLSX.writeFile(wb, null || fileName + "." + (fileType || "xlsx"));

Check out this codepen to see the functionality.

Problem :

I have requirement to export html tables on my web page to multiple sheets excel workbook with xlsx extension.

There are many threads in stackoverflow that tells way to export to xls file but i need to export to xlsx file

I need to do this using JQuery or javascript. Any help would be appreciated.


Comment posted by Pirate

how do you do for

Comment posted by shaik

I mean I found a solution for .xls and using same method putting .xlsx in filename doesn’t work.

Comment posted by Pirate

What is solution for XLS? Are you using external library? May be it is the limitation of that then?

Comment posted by Pirate

Please consider updating your question with the actual code you tried that didn’t work. without looking at the code, it’s impossible to say why one is working but not the other.

Comment posted by shaik

I have modified the question. can someone vote this question up as I have been blocked by stackoverflow