
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
table2excel
Advanced tools
convert and download html tables to a xlsx-file that can be opened in Microsoft Excel
table2excel is a ecma5 compiled vanilla javascript plugin to convert and download
html tables to a xlsx-file that can be opened in Microsoft Excel.
It uses the awesome js-xlsx plugin from Sheet JS as a dependency. Thanks!
<script src="table2excel.js"></script>
<script>
var table2excel = new Table2Excel();
table2excel.export(document.querySelectorAll("table"));
</script>
// npm install table2excel --save
import 'table2excel';
const Table2Excel = window.Table2Excel;
const table2excel = new Table2Excel(options);
See my webpack configuration to see how to get js-xlsx running with webpack in the browser.
You can pass in options as a parameter like new Table2Excel(options).
The currently supported options are:
defaultFileName: The general file name of a downloaded document. Default: 'file'.
Can also be adjusted individually for export as a second parameter, e.g. table2excel.export(table, "cool table");.tableNameDataAttribute: Data attribute name to identify the worksheet name of a table. Default: 'excel-name'.
Usage: <table data-excel-name="Check this out">...</table>. If not set, worksheets are numbered incrementally
from 1.table2excel detects a few special cells by default to display them correctly in Excel:
input[type="text"], select or textarea elementsdata-timestamp on the cell (recommended!)'true', 'false' or checkboxes/radios without text to booleans<ul>...</ul> or <ol>...</ol> list elements to '..., ...'Everything else will just get displayed as simple text. You can easily though add custom type handlers for your own needs:
Table2Excel.extend((cell, cellText) => {
// {HTMLTableCellElement} cell - The current cell.
// {string} cellText - The inner text of the current cell.
// cell should be described by this type handler
if (selector) return {
t: ...,
v: ...,
};
// skip and run next handler
return null;
});
The return value must be a js-xlsx cell object.
If you would like to submit a pull request
with any changes you make, please feel free!
Simply run npm test to test and npm start to compile before submitting pull requests.
Please use the GitHub issue tracker to raise any problems or feature requests.
FAQs
convert and download html tables to a xlsx-file that can be opened in Microsoft Excel
The npm package table2excel receives a total of 241 weekly downloads. As such, table2excel popularity was classified as not popular.
We found that table2excel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.