So i have a xlsx (Excel File) inside my project and i have a javascript file where i want to only read its values Whats the best way
My project structure is as following:
-src
--js
---js function
-files
--excelFile
There is a pretty good module available on NPM.
In vanilla JS, you can import the module by adding this line to your file:
<script lang="javascript" src="dist/xlsx.full.min.js"></script>
The link above will explain how to use the module to read the file contents, but you probably need to use the Acquiring and Extracting Data section.
There is also a good selection of demos, one of which explains how to read the file in your browser:
// XLSX is a global from the standalone script
(async() => {
const url = "http://oss.sheetjs.com/test_files/formula_stress_test.xlsx";
const data = await (await fetch(url)).arrayBuffer();
/* data is an ArrayBuffer */
const workbook = XLSX.read(data);
/* DO SOMETHING WITH workbook HERE */
})();