Initially, when I started working on this requirement, people suggested using any one of the backend libraries to read and convert the excel data into JSON objects. But it is difficult to send requests to the server every time. On the other hand, it was really easy to convert the excel file on the client into a JSON object by using pure JavaScript.
There is a JavaScript plugin XSLX that can be used to read excel files as binary strings and to convert them into JSON objects.
We can read the data in the excel file by using a file reader as a binary string in JavaScript. Then we use XLSX which has a built-in facility of SheetJS to convert our binary string into a JSON object….(read more)
Convert Word 2 PDF: Word to PDF Converter
Convert PowerPoint 2 PDF: PPT to PDF Converter
Convert Excel 2 PDF: Excel to PDF Converter
Convert an Image 2 PDF: Image to PDF Converter
Convert HTML 2 PDF: HTML to PDF Converter
More Tools: PDF Converter
Thank you!!! How did you figure out how to do this? I was scouring the Internet trying to find documentation but to no avail. I started out doing exactly what you told and got as far as using FileReader.readAsBinaryString. Thank you a lot!
Thanks for sharing the technique, it's easy to understand and descriptive.
Hi bro u can share ur project plz? nice tutorial
Like
The expiry date is not showing the correct format. How can we resolve this date and time format issue?
Will it work for multiple sheets as well ?
Do you know if there is a way to convert the Json to a typed object. I tried sheet_to_json<MyModel>, but the json is still just an object and it doesn't know that it is MyModel. It knows it from an intellisense standpoint because typescript is loosely coupled. However, when I try to validate the model using class-validator, it doesn't validate anything because it doesn't know the actual model to look at. I'm trying to do it as generically as possible so I can reuse the code. In other words, I don't want to use Object.assign(MyModel, jsonObject) in order to get it to work because I need MyModel to be generic.
Thank you
How to validate the values after reading? Suppose in your excel file you are having InsVal – its value should be number but what if user enter a-z characters ? How to handle
Nicely Done Bro
gracias, muy buen video 🙂
new subscriber here !
Amazing
Thanks a ton ;
Bro How to use in Require js. In Require Js it's showing error.
woah amazing friend, this works for me 100%, I think just add how to drop a file(because for me didn't work or maybe it's just adding something in the html) and it will be the most complete video about this topic thanks
why u dont have any error in "let binaryData = event.target.result" that the object is possibly null
Can you please tell me how to access the JSON object out of that method. Even though I assign it to global variable, but it is not accessible after the method.. please help me here
can you share the how to convert the excel to json data with using the react please tel me
Nice job man, you have another subscriber! Would you mind showing how to generate the converted json file to folder on the project and not in the dom
100% working…
excellent job