We’ve covered a neat trick that leverages Google spreadsheet as a JSON back-end service API for developers who are making any REST applications. However, the use case of this trick is limited if not difficult to adapt in production applications. Often times there is a layer gap within the raw data format between product managements to end developers. Business people tend to use Microsoft office products to store and exchange information, but when those data needs to be used in a product converting to a different format like JSON the process could be tedious. I’ve personally experienced this, and have found a great solution to help automate any Excel spreadsheet data into customized JSON formats.
This is a step-by-step guide on how to convert any Excel spreadsheet into JSON formats leverage Excel’s Developer features
First, we need to enable Developer tab if you haven’t enabled yet. Go to the start page > Options
Under Excel Options > Customize Ribbon > Developer. Make sure on the right column, Customize the Ribbon the Developer tab is checked.
Now, you will see a new tab called “DEVELOPER” showing, click to expand the menu and click Source. This will launch and expand the XML Source configurations. Click XML Maps … to bring up XML sample datasets or XML schema file (.xsd).
Now, it’s important to understand what’s going on here. We are trying to tell Excel to use XML schema to map the data from spreadsheet columns to the data expected from the XML schema. You don’t need to have a .xsd schema file ready, in fact, the easiest way to tell Excel what your data are going to look like is to create a sample XML with at least two repeated nodes.
Below is an example of a sample XML that contains a repeated item, each will have a model and description field. This is extremely simple to create and whole lot easier than dig your head into XML schema and learning all the new sets of syntax, which itself could take days.
<xml version=”1.0″ encoding=”UTF-8″ ?>
Now click “Add..” to include the sample XML we’ve just created.
At this point, Excel detected that this is not a XML schema, but it understands this is a valid XML and it will generate a schema for us to use based on this sample.xml.
Once you have clicked OK. Excel will show you the generated schema with its corresponding names, root and namespace etc.
Now all you need to do is drag the filed into corresponding columns. OR you can right-click on the model and select the range of elements map to.
What you get after you have successfully mapped the columns is something like above, you will be able to sort and do all kinds things with those data. What we want is to export it into a valid XML file. You can do so by going to DEVELOPER tab and click “Export“.
This will export the data into a XML file and from this point on your life should be much easier. There are online tools out there would help you to convert the XML into JSON. Below is a screenshot that uses http://codebeautify.org/ to convert the XML from Excel schema mapping into JSON.
Hope you find this guide helpful, data conversions between legacy file formats to modern formats can be tedious and troublesome. I’m always a fan of automation, trying to find the right tool and leverage them coherently isn’t an easy task, but once you’ve masted them your life will be whole lot easier.
Co-founder of Next of Windows and a cool geek 🙂
Latest posts by Jonathan Hu (see all)
- Three Alternative Windows Environment PATH Editor - February 18, 2017
- Three Way to Attach or Send Files In Outlook Email - February 14, 2017
- Download Smashing Magazine Desktop Wallpaper Calendar February 2017 Windows 7/8/10 Theme - February 1, 2017
Last updated: 02/10/2015