Git Product home page Git Product logo

tableml's Introduction

TableML

TableML, Table Markup Language, 基于电子表格的标记语言,

类似JSON, XML, INI,TableML可以作为软件项目的配置标记语言,

与之不同的是,您可以使用Excel等电子表格编辑软件来配置TableML,自由地添加图标、注释、VB脚本和预编译指令,再由TableML编译器导出干净的TSV格式的配置表表格,编辑方便,使用简单。

目前提供C#版本的运行时、编译器、代码生成器。

Example

您可以使用Excel编译如下内容,并保存为文件setting/test.xls:

Id #Something Value Comment
int string string string
关键字/注释行 带#开头的注释列 内容 带Comment开头的注释列
1 无用注释 Abcdefg 一些注释
#注释行 无用注释 Abcdefg 一些注释
Comment注释行 无用注释 Abcdefg 一些注释
2 无用注释 Yuiop 一些注释
#if LANG_TW
123 这一行不会被编译 skldfjlj 一些注释
#endif

然后使用TableML命令行编译器:

TableML.exe --Src setting --To setting2 --CodeFile Code.cs

执行后,将会生成setting2/test.tml文件,打开可以看见编译后内容:

Id Value
int string
1 Abcdefg
2 Yuiop

另外附带一份Code.cs,自动生成的代码。

TableML编辑规则

以上的例子中,展示了TableML的大部分特性:

  • TableML使用Excel等电子表格软件作为编辑器,并通过编译器导出成tml格式文件
  • tml格式文件实质是TSV格式,即Tab Sperated Values,类似CSV
  • 行头占3行:
    • 第1行是列名
    • 第2行是列的信息,通常是声明列的类型,可以自定义
    • 第3行是列的注释
    • 除外的所有行为内容
  • 列名内容以#开头或Comment开头,改列被视为注释列,编译器忽略
  • 行内容的第一个单元格内容,以#开头或Comment开头,改行被视为注释行,编译器忽略
  • 可以使用预编译指令#if和#endif,条件式控制编译的行

自动读取配置代码生成

TableML编译器内置Liquid模板引擎。您可以自定义模板内容,来为不同的语言生成读表类。

TableML是KSFramework的一部分,用于游戏配置表读取代码,支持热重载、分表等机制。

TableML for C#/Mono/Xamarin

TableML目前只提供C#版本。当前TableML使用基于Xamarin Studio开发,TableML的C#版本具备了跨平台特性(Windows/Mac/Linux)。

tableml's People

Contributors

dependabot[bot] avatar mr-kelly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tableml's Issues

是否不支持xlsx(office2007)格式?

在WIN10/7 编译xlsx时,出现下面的提示。
提示信息:

D:\Git\TableML\TableML\TableMLCompilerConsole\bin\Debug>TableML.exe -f TestExcel2.xlsx
Filename: TestExcel2.xlsx

未经处理的异常:  System.Exception: 无法打开Excel: TestExcel2.xlsx, 可能原因:正在打开?或是Office2007格式(尝试另存为)? 未能加载文件或程序集ICSharpCode.SharpZipLib, Version=0.86.0.518, Culture=neutral, PublicKeyToken=1b03e6acf1164f73或它的某一个依赖项。系统找不到指定的文件。
   在 TableML.Compiler.SimpleExcelFile.ParseExcel(String filePath) 位置 d:\Git\TableML\TableML\TableMLCompiler\SimpleExcelFile.cs:行号 130
   在 TableML.Compiler.SimpleExcelFile..ctor(String excelPath) 位置 d:\Git\TableML\TableML\TableMLCompiler\SimpleExcelFile.cs:行号 113
   在 TableML.Compiler.Compiler.Compile(String path, String compileToFilePath, String compileBaseDir, Boolean doRealCompile) 位置 d:\Git\TableML\TableML\TableMLCompiler\Compiler.cs:行号 317
   在 TableML.Compiler.Compiler.Compile(String path) 位置 d:\Git\TableML\TableML\TableMLCompiler\Compiler.cs:行号 293
   在 TableCompilerConsole.TableCompilerConsole.Main(String[] args) 位置 d:\Git\TableML\TableML\TableMLCompilerConsole\Program.cs:行号 36

编译xls文件,是正常的。

D:\Git\TableML\TableML\TableMLCompilerConsole\bin\Debug>TableML.exe -f TestExcel.xls
Filename: TestExcel.xls
Compile excel file: TestExcel.xls , to D:\Git\TableML\TableML\TableMLCompilerConsole\bin\Debug\TestExcel.tml

抛异常的130行代码行如下:

       private void ParseExcel(string filePath)
        {
            using (var file = new FileStream(filePath, FileMode.Open, FileAccess.Read,FileShare.ReadWrite)) // no isolation
            {
                try
                {
                    Workbook = WorkbookFactory.Create(file);
                }
                catch (Exception e)
                {
                    throw new Exception(string.Format("无法打开Excel: {0}, 可能原因:正在打开?或是Office2007格式(尝试另存为)? {1}", filePath,
                        e.Message));
                    //IsLoadSuccess = false;
                }
            }

我在ks里导表的时候碰到的一个读取问题

Exception: 无法打开Excel: Product/SettingSource\Billboard.xlsx, 可能原因:正在打开?或是Office2007格式(尝试另存为)? Specified argument was out of the range of valid values.
Parameter name: length
TableML.Compiler.SimpleExcelFile.ParseExcel (System.String filePath) (at e:/Workspace/TableML/TableML/TableMLCompiler/SimpleExcelFile.cs:137)
TableML.Compiler.SimpleExcelFile..ctor (System.String excelPath) (at e:/Workspace/TableML/TableML/TableMLCompiler/SimpleExcelFile.cs:120)
TableML.Compiler.Compiler.Compile (System.String path, System.String compileToFilePath, System.String compileBaseDir, System.Boolean doRealCompile) (at e:/Workspace/TableML/TableML/TableMLCompiler/Compiler.cs:317)
TableML.Compiler.BatchCompiler.CompileTableMLAll (System.String sourcePath, System.String compilePath, System.String genCodeFilePath, System.String genCodeTemplateString, System.String nameSpace, System.String changeExtension, System.String settingCodeIgnorePattern, System.Boolean forceAll) (at e:/Workspace/TableML/TableML/TableMLCompiler/BatchCompiler.cs:177)
KEngine.Editor.SettingModuleEditor.DoCompileSettings (System.Boolean force, System.String forceTemplate, System.Boolean canCustom) (at Assets/KSFramework/KEngine/Editor/KEngine.Editor/SettingModuleEditor.cs:190)
KEngine.Editor.SettingModuleEditor.CompileSettings () (at Assets/KSFramework/KEngine/Editor/KEngine.Editor/SettingModuleEditor.cs:148)

这是因为Office版本的原因么?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.