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 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 importedProtoFiles option of tableauc config to import the common proto files, where predefined enum or struct types are defined. Refer: Tableau Options.

Enum

The basic enum guide, please go to read Enum →

For example, enum type FruitType in common.proto is defined as:

enum FruitType {
  FRUIT_TYPE_UNKNOWN = 0 [(tableau.evalue).name = "Unknown"];
  FRUIT_TYPE_APPLE   = 1 [(tableau.evalue).name = "Apple"];
  FRUIT_TYPE_ORANGE  = 2 [(tableau.evalue).name = "Orange"];
  FRUIT_TYPE_BANANA  = 4 [(tableau.evalue).name = "Banana"];
}

A worksheet ItemConf in HelloWorld.xlsx:

IDType
map<uint32, Item>enum<.FruitType>
Item’s IDFruit’s type
11
2Orange
3FRUIT_TYPE_BANANA

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"}];
    FruitType type = 2 [(tableau.field) = {name:"Type"}];
  }
}
ItemConf.json
{
    "itemMap":  {
        "1":  {
            "id":  1,
            "type":  "FRUIT_TYPE_APPLE"
        },
        "2":  {
            "id":  3,
            "type":  "FRUIT_TYPE_ORANGE"
        }
        "3":  {
            "id":  2,
            "type":  "FRUIT_TYPE_BANANA"
        },
    }
}

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
                }
            ]
        }
    }
}

Variable naming

In horizontal map or horizontal list, you can define custom variable name with the predefined struct.