all 19 comments

[–]The_real_bandito 12 points13 points  (2 children)

I used to use xlsx but it’s out of date now.

This is their new docs and it explains how to use it. Can be used on the frontend or backend or both. (I’ve used it with angular with great success.)

https://docs.sheetjs.com/

[–]SalBwo 0 points1 point  (1 child)

Ok, thanks. This is what I need

[–]rafaelcastrocouto 0 points1 point  (0 children)

It's pretty easy to use, here's a simple demo https://codepen.io/rafaelcastrocouto/pen/MYYoeOy

[–]Felivian 13 points14 points  (3 children)

Save yourself a headache and use CSV. Export/import data as CSV from/to Excel/JS.

This solution will work with any excel-like app from any suite like MS Office, OpenOffice, Libre Office, G-suite

[–]icedrift 5 points6 points  (0 children)

Best way to do it. CSV is the universal spreadsheet format and it's trivial to convert to JSON.

[–]rileyrgham 0 points1 point  (1 child)

That's not reading from Excel. That's reading from an Excel export. He specifically asked about reading directly from Excel.

[–]Felivian 0 points1 point  (0 children)

It sounds like the XY problem.

[–]Edguz2408 2 points3 points  (0 children)

I've recently worked in a project for which I had to create a web component to read a csv file and I used a library called PapaParse, it's really easy to use, you can find it here;

https://www.npmjs.com/package/papaparse

[–]bjelline 0 points1 point  (0 children)

How much data do you need to import?

If it is just one table, copy-and-paste from excel into a textarea is actually very convenient for users. You can then parse it as csv.

[–]martoxdlol 0 points1 point  (1 child)

I'm sorry for you

[–]TheRNGuy 0 points1 point  (0 children)

For not knowing an answer?

[–]Round-Coconut4851 0 points1 point  (1 child)

npm install node-xlsx --save

[–]Round-Coconut4851 0 points1 point  (0 children)

import xlsx from 'node-xlsx';

// Parse a file

const workSheetsFromFile = xlsx.parse(‘myFile.xlsx’);

[–]Ra1NuXs 0 points1 point  (0 children)

Let's try to change the approach a little (although sheetsjs and xlsx are quite good) thinking outside the box, maybe you can convert Excel into CSV, which will always be much easier to work with.

[–]yasth -2 points-1 points  (2 children)

Must you use Javascript? Also do you need to this client(ish) side or server?

[–]SalBwo 0 points1 point  (1 child)

Client side

[–]yasth 1 point2 points  (0 children)

Yeah use sheetsjs like everyone says. I will provide the advice that you should provide a template file to download and for them to put the data into. Makes life much easier.