Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joexi/Excel4Unity
Excel for Unity. Provides both read and write with .xls and .xlsx
https://github.com/joexi/Excel4Unity
Last synced: 3 months ago
JSON representation
Excel for Unity. Provides both read and write with .xls and .xlsx
- Host: GitHub
- URL: https://github.com/joexi/Excel4Unity
- Owner: joexi
- Created: 2015-12-01T10:31:32.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-10-29T02:06:25.000Z (about 5 years ago)
- Last Synced: 2024-05-18T03:33:05.397Z (6 months ago)
- Language: C#
- Homepage:
- Size: 1.2 MB
- Stars: 210
- Watchers: 27
- Forks: 53
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-unity-open-source-on-github - Excel4Unity - Excel for Unity (Excel)
README
# Excel4Unity
Excel for Unity## Provides
* Excel(.xlsx) Read/Write
* Format Excel sheet into custom object (Excel,ExcelTable...)
* Edit .xlsx file in Unity EditorWindow
* Generate .cs model according to .xls
* Conver .xlsx file to JSON format## How to use
#### read & write
``` c#
string excelPath = Application.dataPath + "/Test/Test.xlsx";
string outputPath = Application.dataPath + "/Test/Test2.xlsx";
Excel xls = ExcelHelper.LoadExcel(excelPath);
xls.ShowLog();xls.Tables[0].SetValue(1, 1, "???");
ExcelHelper.SaveExcel(xls, outputPath);
```
#### generate .cs file
``` c#
string path = Application.dataPath + "/Test/Test4.xlsx";
Excel xls = ExcelHelper.LoadExcel(path);
ExcelDeserializer ed = new ExcelDeserializer();
ed.FieldNameLine = 1;
ed.FieldTypeLine = 2;
ed.FieldValueLine = 3;
ed.IgnoreSymbol = "#";
ed.ModelPath = Application.dataPath + "/Editor/Excel4Unity/DataItem.txt";
ed.GenerateCS(xls.Tables[0]);
```
#### convert to json
``` c#
Object[] objs = Selection.objects;
for (int i = 0; i < objs.Length; i++)
{
string path = AssetDatabase.GetAssetPath(objs[i]);
if (path.EndsWith(".xlsx"))
{
Excel4Unity.ParseFile(path);
}
else
{
EditorUtility.DisplayDialog("提示", "暂不支持的文件格式" + path, "ok");
return;
}
}
AssetDatabase.Refresh();
```
## Dependency* EEPlus
* .Net 2.0 instead of .Net 2.0 Subset if you want to do excel job runtime## Version
Unity 4.x or higher