XLSX spreadsheet writer for Node.js and browsers.
npm install tiny-xlsx
import TinyXLSX from 'tiny-xlsx';
let summary = [
['Annual Sales', 40000 ],
['Costs', 30000 ],
['Profit', 10000 ]
];
let transactions = [
['Date', 'Description', 'Amount'],
['2017-01-01', 'Sales', 200 ],
['2017-01-01', 'Sales', -20 ],
['2017-01-01', 'Sales', 1200 ],
['2017-01-01', 'Sales', -10.5 ]
];
let sheets = [
{ title: 'Summary', data: summary },
{ title: 'Transactions', data: transactions }
];
TinyXLSX.generate(sheets)
.write('accounts.xlsx')
.then(() => console.log('done!'));
<script script="https://unpkg.com/tiny-xlsx"></script>
<script>
let data = [
[1, 2]
['hello', 'world']
];
let sheets = [{ title: 'Hello World', data }];
TinyXLSX.generate(sheets)
.base64()
.then(base64 => {
location.href = "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64," + base64;
});
</script>
Generates XLSX file for given array of sheets.
Writes workbook to given filename.
Provides a stream.
Provides a base64 string.
Provides a blob.