Excel to Json Converter

Hi all,

For my games, I tend to put as much of the game data (such as in game item prices, unlock levels etc) as I can out into separate config files to enable tuning the game without needing to modify the code. For this I normally use Excel to create the config files, and then convert them to json so they can be easily read in via code.

Anyway, I’ve made a simple Editor plugin that allows you to convert excel files to json within Unity. You can do it manually via a window or it can be performed automatically whenever Unity refreshes (such as after an script change for example). If this is useful to anybody else, you can grab it from here.

Notes:

  • Supports .xls (1997 - 2004) and .xlsx (2007) excel file formats.
  • Supports multiple sheets per file. Each sheet is saved separately to a Json file with the same name. (e.g. Sheet1 saved to Sheet1.json)
  • Assumes that the first row of a sheet are column headers.
  • If you want to ignore a column and not have it saved in the Json file, prefix the column header with ‘~’. E.G. ~Notes
  • If you want to ignore a sheet and not have it converted to Json, prefix the sheet name with ‘~’. E.G. ~Temp
  • Automatically scans and updates excel files when editor refreshes (e.g. after a script is changed)

Note: This has only been tested on Mac. It should work on Windows also, but you may need to delete the Mono folder within ExcelToJsonConverter directory (otherwise there may be a conflict with System.Data.dll in windows).

5 Likes

Hey Thank you very much, it is really useful

Second that. This is just what I needed

No problem, glad it’s useful to others :slight_smile:

Great plugin. Thanks for it.
It works fine in the editor and when I build it for windows, it doesn’t work.
As you’ve mentioned that we may need to delete the Mono folder for windows, if I delete the Mono folder, it gives error that It cannot find the System.Data file.
I can’t find the issue, can you please help me out in finding what could have been gone wrong in it?

Hi atcae102410,

Sorry I should have specified that this is an editor plugin, it’s designed to only be used within the editor and not in an actual build. The code example I give in github is meant to be called from an editor script, not a game script.

I don’t know what error you are getting, but I assume it can’t find the plugin as it’s in the editor folder which is excluded when doing a build. It may work if you move the plugin folder out of the editor folder, worth a try. Unfortunately I don’t have the time to check it out at the moment, and as I mentioned before it’s not designed for runtime use, so even if it does work, performance may be poor.

You say it works fine in the editor, do you mean in windows? If it works fine in the windows editor, then it appears you do not need to delete the Mono folder after all.

Yes it works fine in window’s editor and I moved the plugin out of Editor folder to test it on windows editor and it worked fine, though never worked on build as you said its an editor plugin. Thanks for clearing it.
Though if you know any other plugin that would work on build at run-time, please mention it, it would be a great help.

I’m not aware of any plugins I’m afraid, thats why I made this one a while back, but I didn’t need it at runtime.

It can`t work…can you help me to solve this problem?

Microsoft (R) Visual C# Compiler version 2.9.1.65535 (9d34608e)
Copyright (C) Microsoft Corporation. All rights reserved.

error CS1703: Multiple assemblies with equivalent identity have been imported: ‘/Users/vin/Desktop/UnityProjects/Roguelike2D/Assets/Editor/ExcelToJsonConverter/Mono/System.Data.dll’ and ‘/Applications/Unity/Hub/Editor/2019.1.0f2/Unity.app/Contents/MonoBleedingEdge/lib/mono/4.7.1-api/System.Data.dll’. Remove one of the duplicate references.

remove Data.dll It`s OK