{"id":36577690,"url":"https://github.com/qi7chen/tabugen","last_synced_at":"2026-01-12T07:38:00.496Z","repository":{"id":37105722,"uuid":"153210722","full_name":"qi7chen/tabugen","owner":"qi7chen","description":"一个表格配置导出和源码生成工具","archived":false,"fork":false,"pushed_at":"2025-06-13T10:14:49.000Z","size":2136,"stargazers_count":14,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-17T01:13:38.581Z","etag":null,"topics":["cplus","csharp","excel-export","golang","java","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qi7chen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-10-16T02:30:55.000Z","updated_at":"2025-07-26T15:26:52.000Z","dependencies_parsed_at":"2024-06-14T10:28:28.033Z","dependency_job_id":"c3d3046f-e51f-4c1b-b3fa-346cf01810d6","html_url":"https://github.com/qi7chen/tabugen","commit_stats":{"total_commits":461,"total_committers":8,"mean_commits":57.625,"dds":"0.42516268980477223","last_synced_commit":"0cc1c88d6ff0e1c1f2d3c4667a1c65c7efc80413"},"previous_names":["qi7chen/tabugen","qki7chen/tabugen","k7tchen/tabugen","qchencc/tabugen"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/qi7chen/tabugen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qi7chen%2Ftabugen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qi7chen%2Ftabugen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qi7chen%2Ftabugen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qi7chen%2Ftabugen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qi7chen","download_url":"https://codeload.github.com/qi7chen/tabugen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qi7chen%2Ftabugen/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28336609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cplus","csharp","excel-export","golang","java","python"],"created_at":"2026-01-12T07:38:00.444Z","updated_at":"2026-01-12T07:38:00.492Z","avatar_url":"https://github.com/qi7chen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tabugen\n\nTabugen是一个配置导出和代码生成工具，主要用于游戏项目中简化业务开发数据抽象过程。\n\nTabugen导入Excel表格生成编程语言的结构体定义，导出CSV数据文件，并生成对应的CSV文件加载代码。\n\n\n## Tabugen解决的几个痛点\n\n写一个从excel表格导出csv和生成对应的业务代码的工具并不难，不好把控的是如何设计格式和流程让设计师和程序员之前更好的沟通，降低理解难道和配置踩坑，\n\nTabugen目前解决了日常使用中的几个痛点：\n\n\n#### 痛点1 基本功能\n\n从excel表格里导出结构体定义，并且把excel转为csv，这个是基本需求\n\n比如我们有一个`HeroConfig.xlsx`文件，里面有如下内容：\n\n | #备注    | ID   | Name | Exp\n |---------|-------|------|-------\n | 流浪剑客 | 1001  | Sven | 2000\n | 冥界亚龙 | 1002  | Viper | 2500\n\n\n* 第一行为字段名称，此名称会原样生成到结构体里；\n* 以`#`开头的字段名在导出的时候会被忽略，可以用于配置一些说明信息；\n* 第二行开始就是具体的数据内容\n\n最后会生成代码如下：\n\n```C++\nstruct HeroConfig {\n    int ID;\n    int Name;\n    int Exp;\n}\n```\n\n不需要单独配置一行来表达类型，也无需在字段名里加上类型前缀（当然要加也支持比如`INT_Exp`），Tabugen会自动根据数据行识别字段类型；\n\n#### 痛点2 字段类型支持简单的数组和字典格式\n\n | #备注  | ID   | Name | Exp  | Buff | Drop\n |------|-------|------|------|------|------------\n| 类型   | int  | string | int64 | int[] | \u003cint,int\u003e\n | 流浪剑客 | 1001  | Sven | 2000  | 1201,1202 | 2001=100,2002=300\n | 冥界亚龙 | 1002  | Viper | 2500 | 1302,1304 | 2001=150,2002=200\n\n* 复杂的组合类型则需要单独用第二行来描述；\n* `int[]`表示数组类型，默认使用竖线`|`分隔元素，格式如：`value1|value2|value3`，分隔符可以在cli里传递`--delim1`来指定；\n* `\u003cint,int\u003e`表示字典类型，默认使用竖线`|`分隔元素，用`：`分隔键值，格式如: `key1:value1|key2:value2`，分隔符可以在cli里传递`--delim1` `--delim2`来指定；\n* 生成的代码如下：\n\n```C++\nstruct HeroConfig {\n    int ID;\n    string Name;\n    int64 Exp;\n    vector\u003cint\u003e Buff;\n    map\u003cint,int\u003e Drop;\n}\n```\n\n#### 痛点3 全局变量表的纵向解析格式\n\n | Key | Type | Vaue | # Desc\n |-----|------|------|------\n | Key1   | float  | 3.14              | 浮点数值\n | Key2   | string | SUCEE             | 显示文字\n | Key3   | bool   | 0                 | 功能开关\n | Key4   | int[] | 1 \u0026#124; 2 \u0026#124; 3 | 等级列表\n\n\n会生成下面格式结构体\n\n```\nstruct Global\n{\n    float Key1;\n    string Key2;\n    bool Key3;\n    int[] Key4;\n}\n```\n\n#### 痛点4，不同项目类型的区分导出\n\n这是一个常见的需求，比如一个excel表格，某些字段只有客户端需要，某些字段只有服务器需要，\nTabugen的做法是通过前缀来实现\n\n | ID   | S_Field1 | C_Field2 | Field3\n |------|---------|-----------|--------\n | 1001 | 1       | 2         | 3\n\n\n* 如果是仅服务器使用的字段，字段名的前缀加上`S_`，导出的时候指定选项`--project_kind=S`，这样会解析到不带前缀的和带`S_`前缀的字段；\n* 如果是仅客户端使用的字段，字段名的前缀加上`C_`，导出的时候指定选项`--project_kind=C`，这样会解析到不带前缀的和带`C_`前缀的字段；\n\n\n## 如何使用Tabugen(How to Use)\n\n\n### 从pip导入\n\n```\npip install tabugen\ntabugen --asset_path=example.xlsx --cpp_out=MyConfig --package=config  --gen_csv_parse --source_file_encoding=utf_8_sig\n```\n\n这是推荐的方式，pip可以和项目的CI/CD更好的集成\n\n### 从源码打包\n\n* `git clone https://github.com/qi7chen/tabugen.git`\n* `cd tabugen \u0026\u0026 python -m PyInstaller --name \"tabugen\" -F tabugen/__main__.py`\n\n\n## 几种主流强类型语言的示例\n\n请查看[examples](examples)目录下的示例工程：\n\n* C++的示例 [examples/Cpp](examples/Cpp) 演示如何配合C++使用;\n* C#的示例 [examples/CSharp](examples/CSharp) 演示如何配合C#(Unity)使用;\n* Golang的示例 [examples/Go](examples/Go) 演示如何配合Golang使用;\n* 对于Python, JavaScript等动态语言，将Excel导出为json即可，指定选项`--out_data_format=json`\n* 对于其它未实现语言，可以自行fork后适配\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqi7chen%2Ftabugen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqi7chen%2Ftabugen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqi7chen%2Ftabugen/lists"}