I am trying to work with an excel file using xlsx.js.
import xlsx from "xlsx";
const workbook = xlsx.readFile("../data/data.xlsx");
const worksheet = workbook.Sheets["22.07_STUDENT"];
const arr = xlsx.utils.sheet_to_json(worksheet);
console.log(arr);
I have typed the correct file address and still getting this result
PS D:\Ecell\p1\server> ts-node "d:\Ecell\p1\server\src\server.ts"
Error: ENOENT: no such file or directory, open '../data/data.xlsx'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at read_binary (d:\Ecell\p1\server\node_modules\xlsx\xlsx.js:3153:44)
at readSync (d:\Ecell\p1\server\node_modules\xlsx\xlsx.js:23698:69)
at Object.readFileSync (d:\Ecell\p1\server\node_modules\xlsx\xlsx.js:23738:9)
at Object.<anonymous> (d:\Ecell\p1\server\src\server.ts:4:23)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module.m._compile (C:\Users\Aditya\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1618:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Object.require.extensions.<computed> [as .ts] (C:\Users\Aditya\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:1621:12) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: '../data/data.xlsx'
}
What am I doing wrong here?
I also tried clearing the cache and using fs module, but didn't help