I am using this package: https://www.npmjs.com/package/xlsx
However I can have some very large excel files that could contain 1 million rows.
I tested with 600K rows which is about 15mb excel file and my code is already crashing on localhost.
Is there away to stream it in? I know the documentation says they don't have any sort of streaming api but it talks about buffering?
var reader = new FileReader();
reader.onload = evt => {
const bstr = evt.target.result;
const wb = XLSX.read(bstr, { type: "binary" });
const wsname = wb.SheetNames[0];
const ws = wb.Sheets[wsname];
const data = XLSX.utils.sheet_to_json(ws, { header: "A", defval: "" });
});
};
reader.readAsBinaryString(this.file);
xlsx into an empty directory. Open a terminal window in that directory, then type: unzip your-file-name. xlsx.
Apache POI is able to handle both XLS and XLSX formats of spreadsheets. Some important points about Apache POI API are: Apache POI contains HSSF implementation for Excel '97(-2007) file format i.e XLS. Apache POI XSSF implementation should be used for Excel 2007 OOXML (.
This can be done quite easily using SheetJS. import { read, writeFileXLSX, utils } from "https://cdn.sheetjs.com/xlsx-0.18.7/package/xlsx.mjs"; const workbook = read(data, { type:'binary', }); data is the binary string resulting from reading an Excel file as a binary string with the FileReader API.
When I had to read data from a very large excel file ( about 50 mb), I converted it to csv on the backend with Excel Interop, which takes shorter time than getting data from Excel file. Then, just get the first n number of lines via stream reader. Which will give you the required data to preview. Send this to the front-end for preview. This is what I would do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With