核心概念

Tableau 核心概念。

术语

基础术语

术语定义
Workbook一个 Excel 文件;或一组以相同前缀命名、用 # 分隔的 CSV 文件;或一个 XML 文件;或一个 YAML 文件。
WorksheetExcel 文件中的一个 sheet;或一个 CSV 文件;或 XML 文件的根节点;或 YAML 文件中的一个文档。
Metasheet名为 @TABLEAU 的特殊 worksheet,用于指定 tableau 解析器选项。
Rowsheet 中的一行。
Columnsheet 中的一列。
Cell行与列的交叉点(单元格)。
In-cell单元格内部。
Cross-cell一行或一列中连续的多个单元格。

Worksheet 相关术语

术语定义
Namerowworksheet 中列名定义所在的行号。
⚠️ 注意:同一 worksheet 中每个列名必须唯一!
默认值:1
Typerowworksheet 中列类型定义所在的行号。
默认值:2
Noterowworksheet 中列注释所在的行号。
默认值:3
Datarowworksheet 中数据起始行号。
默认值:4
Nameline单元格内列名定义所在的行号,0 表示整个单元格。
默认值:0
Typeline单元格内列类型定义所在的行号,0 表示整个单元格。
默认值:0
Sep分隔符,用于:
1. 分隔 in-cell list 的元素。
2. 分隔 in-cell map 的条目。
默认值:,
Subsep子分隔符,用于分隔 in-cell map 的 Key-Value 对。
默认值::
Nestednamerow 的嵌套命名方式。
默认值:false
LayoutIncell(单元格内)、vertical(跨单元格纵向)或 horizontal(跨单元格横向)。
Transpose对指定 sheet 进行行列转置。

与 Protoconf 的映射关系

术语Protoconf
Workbook一个 protoconf(.proto)文件。
Worksheetprotoconf 文件中的一个顶层 message(名为 @TABLEAU 的 metasheet 除外)。
columnmessage 中的一个字段。

简单映射示例

输入:一个 Excel 文件

一个工作簿(HelloWorld.xlsx),包含两个数据 worksheet(ItemConfActivityConf)以及一个空的 tableau metasheet(@TABLEAU)。

IDNameType
map<uint32, Item>stringint32
Item’s ID.Item’s name.Item’s type.
1item1100
2item2200
3item3300
IDNameOpen
map<uint32, Activity>stringbool
Activity’s ID.Activity’s name.Activity is open?
1activity1true
2activity2false
3activity3

输出:一个 protoconf 文件

一个 protoconf 文件(hello_world.proto),包含两个顶层 message(ItemConfActivityConf)。

hello_world.proto
syntax = "proto3";
package protoconf;
option go_package = "github.com/tableauio/demo/examples/helloworld/protoconf";

import "tableau/protobuf/tableau.proto";

option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf"};

  map<uint32, Item> item_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
  message Item {
    uint32 id = 1 [(tableau.field) = {name:"ID"}];
    string name = 2 [(tableau.field) = {name:"Name"}];
    int32 type = 3 [(tableau.field) = {name:"Type"}];
  }
}

message ActivityConf {
  option (tableau.worksheet) = {name:"ActivityConf"};

  map<uint32, Activity> activity_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
  message Activity {
    uint32 id = 1 [(tableau.field) = {name:"ID"}];
    string name = 2 [(tableau.field) = {name:"Name"}];
    bool open = 3 [(tableau.field) = {name:"Open"}];
  }
}