'ExcelJS not importing xlsx data
- I'm NOT using the node load option
- External js files ARE being called and loaded
- The xlsx file to be imported IS local to the published files
- This is the script so far - all I want to do is check to see if the source is being imported and populating the created workbook
var workbook = new ExcelJS.Workbook();
var importBook = "./story_content/external_files/sample.xlsx";
console.dir( importBook );
workbook.xlsx.readFile( importBook );
console.dir ( workbook );
var ws = workbook.getWorksheet("Sheet1");
console.dir( ws );
line 112 is the result of console.dir ( workbook ); which says to me that NOTHING is either loaded OR imported, and I can't understand why not....wasted too much time trying possible solutions so i'm reaching out to the community.
Thanks in advance for any insight
Solution 1:[1]
- You can try this.
const filePath: string = `assets/1962.xlsx`;
const buffer = await fetch(filePath).then(res => res.arrayBuffer());
const workbook = new Workbook();
await workbook.xlsx.load(buffer);
const worksheet = workbook.getWorksheet(1);
console.dir(worksheet);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | skypesky |

