DEV Community

Cover image for Convert XLSX file into JSON
Michael Willian Santos
Michael Willian Santos

Posted on

Convert XLSX file into JSON

// start

Hi everyone!
GitHub of the Project


I was working into a PaaS that requires to read a .xls|xlsx file and extract the data into a readable .json, in which will be sent for the database. Seeking around the web, I found the amazing 'mongo-xlsx', however, the data generated was a messy. So, I had the idea to create a package around the 'mongo-xlsx', in which I would use the other package 'string-similarity', to construct a better parse. In the end, it worked as I wanted and needed for the project. Then, I had decide to construct a 'better one' from the one I have built to share with everyone. Please, if you can contribute with pull-requests, do it. I guess that this package can be pretty useful for everyone to use :)


// How To Use

The package is really simple to use. By justing taking a look at the main README.md and the examples, I guess that you guys can see how to use. However, whatever doubt about it, just ask here :)


// Use Case

As given by the example intermediate, the main motive that leads me to create this package, it is an application that I'm making. I had the problem and the needs to convert a lot of .xlsx file into .json one for the Database. The big problem of this, is that the .xlsx was pretty complex (from stock market).

With this package, I could transform that .xlsx file from the cover page, into a .json data. Example:

Alt Text

Sure thing, after it, there is the need to sanitize and so on.


// End

I hope that this package — that will be improved by time, helps someone in their needs. Please, if you can, contribute to the project. I guess that it will help a lot of people xD

Top comments (2)

Collapse
 
xuri profile image
xuri

I would really recommend trying this library:

github.com/xuri/excelize

Excelize is a library written in pure Go providing a set of functions that allow you to write to and read from XLSX / XLSM / XLTM files. Supports reading and writing spreadsheet documents generated by Microsoft Excel™ 2007 and later. Supports complex components by high compatibility, and provided streaming API for generating or reading data from a worksheet with huge amounts of data.

https://xuri.me/excelize/images/excelize.svg

Collapse
 
daxsoft profile image
Michael Willian Santos

Oh, thank you man! It shall be a huge help