Sometimes, we want to parse Excel (XLS) file in JavaScript and HTML5.
In this article, we’ll look at how to parse Excel (XLS) file in JavaScript and HTML5.
How to parse Excel (XLS) file in JavaScript and HTML5?
To parse Excel (XLS) file in JavaScript and HTML5, we can use the read-excel-file
library.
To install it, we run
npm install read-excel-file --save
Then we write
import readXlsxFile from "read-excel-file";
const input = document.getElementById("input");
input.addEventListener("change", async () => {
const data = await readXlsxFile(input.files[0]);
});
to select the input with getElementById
Then we call addEventListener
on it with 'change'
and a callback that calls readXlsxFile
to read the select file.
We get the read data from data
which is an array of rows with each row being an array of cells.
Conclusion
To parse Excel (XLS) file in JavaScript and HTML5, we can use the read-excel-file
library.