Jump to content

How to read Excel in Javascript?

vikas_jk
Go to solution Solved by kirashi,
12 minutes ago, vikas_jk said:

Hello, I am trying to read excel in Javascript, but I am not able to do so, can you guys provide me short code for it or may link to any tutorial?

Thanks.

 

I don't do much Javascript these days because I can't wrap my head around why we need 100+ libraries, but anywho... looks like most people would convert an XLSX file into something Javascript native like JSON, then manipulate the data as needed.

https://stackoverflow.com/questions/8238407/how-to-parse-excel-xls-file-in-javascript-html5

12 minutes ago, vikas_jk said:

Hello, I am trying to read excel in Javascript, but I am not able to do so, can you guys provide me short code for it or may link to any tutorial?

Thanks.

 

I don't do much Javascript these days because I can't wrap my head around why we need 100+ libraries, but anywho... looks like most people would convert an XLSX file into something Javascript native like JSON, then manipulate the data as needed.

https://stackoverflow.com/questions/8238407/how-to-parse-excel-xls-file-in-javascript-html5

Desktop: KiRaShi-Intel-2022 (i5-12600K, RTX2060) Mobile: OnePlus 5T | Koodo - 75GB Data + Data Rollover for $45/month
Laptop: Dell XPS 15 9560 (the real 15" MacBook Pro that Apple didn't make) Tablet: iPad Mini 5 | Lenovo IdeaPad Duet 10.1
Camera: Canon M6 Mark II | Canon Rebel T1i (500D) | Canon SX280 | Panasonic TS20D Music: Spotify Premium (CIRCA '08)

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...
7 hours ago, Wictorian said:

Can we do this with google sheets?

Not sure about google sheets, but I tried this solution using MS Excel

https://qawithexperts.com/article/javascript/read-excel-file-using-javascript-xlsx-or-xls/239


OR try solution from this 

https://stackoverflow.com/questions/8238407/how-to-parse-excel-xls-file-in-javascript-html5

both of the links are helpful.

Link to comment
Share on other sites

Link to post
Share on other sites

On 7/21/2021 at 2:31 AM, vikas_jk said:

Hello, I am trying to read excel in Javascript, but I am not able to do so, can you guys provide me short code for it or may link to any tutorial?

Thanks.

 

 

Well first off one thing you need to specify is if you're doing this in your browser (client side javascript), or on your local server (server side/node).

As previously mentioned there are solutions available for node.  There are likely dozens of libraries capable of doing this in the browser, however normally node solutions tend to infect search results when you're looking for client side javascript solutions.

With that being said you might want to check out this post for a browser based solution (note: i haven't tested it myself).

https://stackoverflow.com/questions/8238407/how-to-parse-excel-xls-file-in-javascript-html5

 

Another important thing to bear in mind is that there are several different excel formats. XLS and XLSX are NOT the same thing at all, and will likely require different solutions (though if you have a library that works for one format you might as well try the other).

 

Additionally Excel itself can read a bunch of other file types and convert them to spreadsheets.  CSV, TSV, and html tables are just a few examples.

You can rename any of those file types to .XLS or XLSX and Excel will pretty much parse it without issue.

 

The simplest solution on your end though would to be to just have the user convert the file to a csv before hand and upload that.  At that point you're just working with a plain text file, which would be a lot easier.

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

On 8/4/2021 at 12:34 AM, JacobFW said:

 

Well first off one thing you need to specify is if you're doing this in your browser (client side javascript), or on your local server (server side/node).

As previously mentioned there are solutions available for node.  There are likely dozens of libraries capable of doing this in the browser, however normally node solutions tend to infect search results when you're looking for client side javascript solutions.

With that being said you might want to check out this post for a browser based solution (note: i haven't tested it myself).

https://stackoverflow.com/questions/8238407/how-to-parse-excel-xls-file-in-javascript-html5

 

Another important thing to bear in mind is that there are several different excel formats. XLS and XLSX are NOT the same thing at all, and will likely require different solutions (though if you have a library that works for one format you might as well try the other).

 

Additionally Excel itself can read a bunch of other file types and convert them to spreadsheets.  CSV, TSV, and html tables are just a few examples.

You can rename any of those file types to .XLS or XLSX and Excel will pretty much parse it without issue.

 

The simplest solution on your end though would to be to just have the user convert the file to a csv before hand and upload that.  At that point you're just working with a plain text file, which would be a lot easier.

 

 

 

If you have done coding, then you can see I have mentioned only JS, not NodeJS, so yes it was for client side only.
thanks.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...
On 8/3/2021 at 2:04 PM, JacobFW said:

The simplest solution on your end though would to be to just have the user convert the file to a csv before hand and upload that.  At that point you're just working with a plain text file, which would be a lot easier.

This is the solution, convert whatever format the user provides to CSV and then go from there.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×