How to convert Excel to HTML and JSON and vice versa
Tags: html, javascript, rust, webassembly
Published: 2020-02-28 10:59:42

No doubt, Excel is the most popular tool for data processing starting from simple Excel tables with prices and products to complex financial data. With the rapidly developing world wide web, the need to display data from Excel files on websites and web apps arouse. How to efficiently convert Excel into web-based formats?   

[DHTMLX](https://dhtmlx.com/ "DHTMLX") development team created three open source tools, which convert Excel data into the JSON format (and vice versa) and generate HTML tables from Excel files. 

### Based on WebAssembly and Rust

All three libraries were developed using the [WebAssembly](https://webassembly.org/ "WebAssembly") standard and [Rust](https://www.rust-lang.org/ "Rust") programming language. These technologies contribute to highly reliable code and fast performance. There are no vulnerabilities in the process of conversion, and you don’t have to worry about the safety of your data while it’s being processed. The small size of code allows you to perform the operations extremely quickly. Thus, you can use our open-source tools in your projects to maintain high-speed and secure websites and web apps.

### Turning your Excel data into JSON and back

The first two open-source libraries enable you to transform the data kept in your Excel files into the JSON format and back from JSON to Excel. You can find a detailed description and instructions on GitHub:

- [Excel2Json converter](https://github.com/dhtmlx/excel2json "Excel2Json converter")
- [Json2Excel converter](https://github.com/dhtmlx/json2excel "Json2Excel converter")

You can install the libraries in two ways: via [npm](https://www.npmjs.com/ "npm") or [cdn](https://cdnjs.com/ "cdn"). After the data conversion, you’ll have both data and styles saved in Excel or JSON.

One of the most common use cases, when you might need to convert Excel into JSON and vice versa, is embedding your Excel sheets into a web-based spreadsheet. For example, our [JavaScript spreadsheet](https://dhtmlx.com/docs/products/dhtmlxSpreadsheet/ "JavaScript spreadsheet") makes use of the Excel2Json and Json2Excel libraries to provide end users with the ability to import and export Excel files. The spreadsheet has a set of features for further styling and formatting data to achieve the desired appearance.

### Displaying Excel data as HTML tables

The third open-source tool [Excel2Table](https://dhtmlx.com/docs/products/excel-to-html/) was built on the basis of the Excel2Json library, which parses Excel files. The data is rendered as an HTML table preserving all the styles from Excel sheets.

Using the Excel2Table is very straightforward and simple:

1) The first step is to run the following command line to install the library:

```javascript
npm i excel2table
```

2) Then import the library into your project:
```javascript
import "excel2table";
```

3) And all that is left is to call the render function:
```javascript
excel2table.render(html_container, data, config);
```
You can find all the parameters of this function and other technical details described in our [GitHub repository](https://github.com/dhtmlx/excel2table "GitHub repository").

As a result, you’ll have a precise HTML version of your Excel sheet:

![HTML Table from Excel File](https://dev-to-uploads.s3.amazonaws.com/i/ks8eyvpdhjm5s0k982h7.png)

All three libraries are distributed under the [MIT](https://en.wikipedia.org/wiki/MIT_License "MIT") license, which allows for using them both in non-commercial and commercial projects.

### About DHTMLX

DHTMLX team specializes in the development of JavaScript libraries for enterprise web apps with a strong focus on project management and [JS Gantt chart](https://dhtmlx.com/docs/products/dhtmlxGantt/ "JS Gantt chart") as the leading PM solution. In 2019 we also launched the [Suite UI widget library](https://dhtmlx.com/docs/products/dhtmlxSuite/ ""UI widgets) with data processing and visualization widgets compatible with React, Angular, and Vue.js.

Originally published at https://dhtmlx.com/blog/convert-excel-file-html-json-dhtmlx-open-source-tools/