feat(refactor): introduce configuration-based Excel table processing

- Replace command-line options with single tables file configuration
- Add TablesConfig class for parsing table configuration from Excel
- Add TableEntry class for storing table configuration data
- Change GetCellValue method visibility from static to internal static
- Simplify Program.cs command line interface with single --tables option
- Add error handling for missing files and directories
- Update README with new usage instructions and examples
- Remove deprecated command-line option descriptions
This commit is contained in:
2026-04-13 12:37:16 +08:00
parent 0f32860526
commit 965998b56f
4 changed files with 139 additions and 82 deletions
+14 -30
View File
@@ -1,11 +1,6 @@
# ExcelTool(Unity打表工具)
通用Excel打表工具
#### 前言
目前项目中用的csv转json工具,会带来严重的gc性能问题,例如启动加载慢,影响帧率等问题,转成的json数据,我们需要手动写对应的解析模板代码,所以针对以上问题,本通用打表工具应运而生,用二进制数据替代json数据会比较好的解决性能问题,而且能够自动生成对应的模板代码,节省了写重复代码的时间,而且二进制数据比json读取速度更快,文件大小更小。
# ExcelTool
本项目基于 https://github.com/dingxiaowei/ExcelTool 开发。用于 [AudioSystem](https://github.com/htw128/UnityAudioExtend), [HapticSystem](https://github.com/htw128/UnityAudioExtend#Haptic) 导出数据使用。
#### 功能
@@ -22,16 +17,9 @@
* 支持自定义字段 vector,例如[1,2,3]
* 支持自定义字段 list,其实是vector数组,例如[[1,2,3],[2,3,4],[4,5,6]]
#### 效果
![](img/1.gif)
![](img/2.jpg)
相比较json,二进制文件大小只有其1/4
##### 自动生成的模板代码
```
```c#
/*
* auto generated by tools(注意:千万不要手动修改本文件)
* avatarguideTest
@@ -197,7 +185,7 @@ public partial class avatarguideTestConfig : IBinarySerializable
##### 解析二进制文件
```
```c#
IBinarySerializable newavList = new avatarguideTestList();
var readOK = FileManager.ReadBinaryDataFromFile(Path.Combine(path, "avatarguideTest.dat"), ref newavList);
if (readOK)
@@ -216,7 +204,7 @@ else
将二进制文件(后缀必须是.bytes)放在Resources目录,然后通过Resources.Load接口加载
```
```c#
var bytes = Resources.Load<TextAsset>("avatarguideTest");
if (bytes == null)
{
@@ -242,7 +230,7 @@ else
#### 泛型读表
```
```c#
T ReadTable<T>(string tableName) where T : IBinarySerializable, new()
{
var bytes = LoadTextAsset(tableName);
@@ -265,7 +253,7 @@ return default(T);
##### 查询数据
```
```c#
var avatarguideTest = (avatarguideTestConfig)newavList;
var obj = avatarguideTest.QueryById(2);
if (obj != null && obj.Count() > 0)
@@ -274,7 +262,7 @@ if (obj != null && obj.Count() > 0)
#### 自动化拷贝批处理
```
```batch
@echo off
echo "开始拷贝jsons"
@@ -292,21 +280,17 @@ pause
上面的config类采用的是partical class 就是为了方便扩展自定义的方法,如果想要添加自定义方法也定义一个partical class文件作为扩展即可
#### 待扩展的功能
目前还不是最理想的状态,还有很多可以扩展完善的功能,如下:
#### TODO
* [x] 支持枚举类型
* [ ] 支持生成各种类型的文件,例如json、xml、proto、lua等
* [ ] 支持生成各种语法的模板代码
* [ ] 支持不同表不同namespace
* [ ] 支持Excel数据配置规范性检测,例如手误配置不符合规范导致加载异常,例如大小写逗号(肉眼容易忽略),或者空格等等
* [ ] 支持Excel字段客户端服务器可选项
* [ ] ID不能重复
* [ ] MusicContainer不能自引用
* [ ] 同时播放的音乐BPM必须一致
* [ ] 生成CueSheet避免magic number
* [ ] 支持更多自定义数据类型扩展
#### 代码
https://github.com/dingxiaowei/ExcelTool 喜欢麻烦点个star吧
#### Unity客户端使用范例
采用的美术效果机型适配商业化解决方案Demo