I working on export html table to excel using JAVASCRIPT . I face issue it not export to excel office New version with extension xlsx .
but it working fine and export to old version office excel with extension xls .
when export from html table to excel new version with xlsx extension it give me error
cannot open file `.xlsx` because file extension is not valid or file corrupted .
so How to solve this issue to working with xlsx extension and open new version excel .
code for html and javascript that not export to excel new version xlsx
when debug var table it give me html table script as fiddle below so How to export to excel xlsx New version
html table generated by var table from debug

Abhishek ChadhaRank #402 · 6.2K reputationPosted May 17, 2024, 1:00 AM EDT
To export HTML table data to an Excel file with the
.xlsxextension (compatible with newer versions of Excel), you'll need to use a JavaScript library that supports creating Excel files with that format. One popular library for this purpose is SheetJS. Here's how you can modify your code to use SheetJS for exporting:.xlsxextension:function exportToExcel() { var wb = XLSX.utils.table_to_book(document.getElementById('your-table-id')); XLSX.writeFile(wb, 'filename.xlsx'); }Replace
'your-table-id'with the ID of your HTML table, and'filename.xlsx'with the desired name for the Excel file.With this code, SheetJS will convert your HTML table to an Excel file with the
.xlsxextension, which should be compatible with newer versions of Excel.ahmed salahRank #1,744 · 866 reputationPosted May 17, 2024, 9:52 AM EDT
I need to allow sheetjs on function below to export html table to excel xlsx using javascript
i need to export var table to excel using sheet js so how to do that please
function getselected_civilid() { debugger var selectedCivilIds = []; $("input[name='statusCheckbox']:checked").each(function () { selectedCivilIds.push($(this).val()); }); if (selectedCivilIds.length > 0) { // Create an HTML table with headers var table = "???? ????? ?????????? ?????????? ????? ???????????? ????????????????????????? ?????? ????????? ??????????????????? ????? ????????????????? ?????????????? ??????????"; $("input[name='statusCheckbox']:checked").each(function () { var row = $(this).closest("tr"); // Get the parent row of the checkbox var cells = row.find("td"); // Get all the cells in the row table += ""; cells.each(function () { table += "" + $(this).text() + ""; // Add each cell value to the table }); table += ""; }); table += ""; var blob = new Blob([table], { type: "application/vnd.ms-excel;charset=utf-8" }); var link = document.createElement("a"); link.href = URL.createObjectURL(blob); link.download = "LastData.xls"; // Set the filename for the downloaded file link.click(); } }`