Predefined types
Tableau support predefined types to be imported, then you can use it in Excel/CSV/XML/YAML.
Overview
You can define enum
or struct
types in a protoconf file (such as common.proto
) ahead. It means you can create predefined types, and then can use them to specify the column type or cross-cell struct type of a worksheet.
Usage
- Syntax: prepend a dot
.
to predefinedCustomType
(a.k.a..CustomType
) when you use it in a worksheet. - Import: specify the
protoFiles
option of tableauc config to import the common proto files, where predefinedenum
,struct
,union
types are defined. See Tableauc config.
Enum
TODO…
Struct
For example, struct type Prop
in common.proto
is defined as:
message Prop {
int32 id = 1 [(tableau.field).name = "ID"];
int32 value = 2 [(tableau.field).name = "Value"];
}
A worksheet ItemConf
in HelloWorld.xlsx:
ID | Prop1ID | Prop1Value | Prop2ID | Prop2Value |
---|---|---|---|---|
map<uint32, Item> | [.Prop]int32 | int32 | int32 | int32 |
Item’s ID | Prop1’s ID | Prop1’s value | Prop2’s ID | Prop2’s value |
1 | 1 | 100 | 2 | 200 |
2 | 3 | 300 | 4 | 400 |
3 | 5 | 500 |
Generated:
hello_world.proto
// --snip--
import "common.proto";
option (tableau.workbook) = {name:"HelloWorld.xlsx"};
message ItemConf {
option (tableau.worksheet) = {name:"ItemConf" namerow:1 typerow:2 noterow:3 datarow:4};
map<uint32, Item> item_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
message Item {
uint32 id = 1 [(tableau.field) = {name:"ID"}];
repeated Prop prop_list = 2 [(tableau.field) = {name:"Prop" layout:LAYOUT_HORIZONTAL}];
}
}
ItemConf.json
{
"itemMap": {
"1": {
"id": 1,
"propList": [
{
"id": 1,
"value": 100
},
{
"id": 2,
"value": 200
}
]
},
"2": {
"id": 2,
"propList": [
{
"id": 3,
"value": 300
},
{
"id": 4,
"value": 400
}
]
},
"3": {
"id": 3,
"propList": [
{
"id": 5,
"value": 500
}
]
}
}
}
Custom named struct
In horizontal map
or horizontal list
, you can define custom variable name with the predefined struct. See Custom named struct.
Union
TODO…