My friend asked me to make for a simple application to generate charts (bar, curves) from an Excel file. I opted to use JavaScript as a language since I know already the powerful chart.js. However before using chart.js, I have to gather data from the Excel file. So how to read an Excel file via JavaScript?
After some research I have managed to do this with Internet Explorer with (using ActiveX), but I need it to work across browsers.
To get more information about the data stored inside the excelData variable related to the excel file, you can print the variable using the console. log() function. Copy const XLSX = require('xlsx') ; const parseExcel = (filename) => { const excelData = XLSX. readFile(filename); return Object.
An Excel add-in interacts with objects in Excel by using the Office JavaScript API, which includes two JavaScript object models: Excel JavaScript API: Introduced with Office 2016, the Excel JavaScript API provides strongly-typed objects that you can use to access worksheets, ranges, tables, charts, and more.
Set Up the JavaScript Spreadsheet Project. Add Excel Import Code. Add Data to the Imported Excel File. Add a Sparkline.
There are JavaScript libraries which allow XLS & XLSX to be parsed in pure JavaScript. I tested with Chrome (albeit on Windows) and it worked fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With