Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I read an Excel File with JavaScript (without ActiveXObject)

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.

like image 595
Slifer Avatar asked May 19 '13 00:05

Slifer


People also ask

How do you read data from excel using JavaScript?

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.

Can JavaScript interact with excel?

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.

How do I import an XLSX file into JavaScript?

Set Up the JavaScript Spreadsheet Project. Add Excel Import Code. Add Data to the Imported Excel File. Add a Sparkline.


1 Answers

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.

like image 118
Robert MacLean Avatar answered Oct 18 '22 22:10

Robert MacLean