To parse Excel (XLS) file in JavaScript, we use the read-excel-file
package.
To install it, we run
npm i read-excel-file
Then we add an input with
<input type="file" id="input" />
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 querySelector
.
And then we add a change event listener with addEventListener
.
We call readXlsxFile
with the selected file to get a promise with the read Excel data as nested array.