Totally lost here. Tried many different things, but nothing worked. I have a react js electron project, where i need to use some data from excel file. I installed xlsx module. However, got stuck when trying to read file from the component. It works well when I upload the file. But i need file to be in the folder. File is located in folder called "files", the file name is "rent.xlsx" Component is in the same folder as "files" folder, so path should be "./files/rent.xlsx" However, it doesnt read file. Here is the code:
const workbook = XLSX.read("/files/rent.xlsx", { type: "array" });
const sheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[sheetName];
const json: any = XLSX.utils.sheet_to_json(worksheet)
As i have mentioned, reading from uploaded file works well. So, code is OK. This part must be wrong:
XLSX.read("/files/rent.xlsx", { type: "array" });
Please, advise what should i do? Am i missing some libraries or modules? Been looking on stackoverflow, but didnt find anything Thanks!