I am working on some react web app in which I am trying to read excel file on client side as below.
import XLSX from "xlsx";
const targetCsvPath = window.location.origin + "/XRayConfig.xlsx";
const workbook = XLSX.readFile(targetCsvPath)
const json = XLSX.utils.sheet_to_json(workbook.Sheets.FOV);
But this gives error TypeError: _fs.readFileSync is not a function. When I run this code snippet using node, it runs flawlessly. I think client side JavaScript does not run on Node, so is the error.
window.location.origin
points to public folder of react app and the excel file is in that folder.
This link almost answers this question, but excel file is uploaded from client side using input tag and then it is processed. But My excel file is on server side. How can I solve this?