Preview the .xlsx in the browser, convert to HTML with styles. The dependencies of this package is exceljs, it build the pretty preview by exceljs. And it can run in a Worker.
Jump to the demo page
npm install xlsx-preview
or
yarn add xlsx-preview
const xlsxPreview = require('xlsx-preview'); import xlsxPreview from 'xlsx-preview';Before import xlsxPreview.js on browser, you need import excel.js first.
<script src="exceljs.js"></script>
<script src="xlsxPreview.js"></script> // ...
const result = await xlsxPreview.xlsx2Html(data, options);The data can be one of the types, ArrayBuffer, Blob, or File.
The options is optional.
export interface XlsxOptions {
output?: "string" | "arrayBuffer";
separateSheets: boolean;
minimumRows: number;
minimumCols: number;
}options.output: default"string", set the output format, string or ArrayBuffer.separateSheets: defaultfalse, whether the worksheets needs to be separated.- If
separateSheets: true, theresultwill be an Array.
- If
minimumRows: default20, Regardless of whether the worksheet has enough rows, the minimum number of rows generated.minimumCols: default16, Regardless of whether the worksheet has enough cols, the minimum number of cols generated.