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 predefined CustomType (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 predefined enum, 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:

IDProp1IDProp1ValueProp2IDProp2Value
map<uint32, Item>[.Prop]int32int32int32int32
Item’s IDProp1’s IDProp1’s valueProp2’s IDProp2’s value
111002200
233004400
35500

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…