Struct in list

Excel nesting specification of struct in list.

Nested in vertical-list

Struct in vertical-list

A worksheet ItemConf in HelloWorld.xlsx:

IDNamePropIDPropValue
[Item]uint32string{Prop}int32int64
Item’s IDItem’s nameProp’s IDProp’s value
1Apple110
2Orange220
3Banana

Generated:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx"};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf" namerow:1 typerow:2 noterow:3 datarow:4};

  repeated Item item_list = 1 [(tableau.field) = {layout:LAYOUT_VERTICAL}];
  message Item {
    uint32 id = 1 [(tableau.field) = {name:"ID"}];
    string name = 2 [(tableau.field) = {name:"Name"}];
    Prop prop = 3 [(tableau.field) = {name:"Prop"}];
    message Prop {
      int32 id = 1 [(tableau.field) = {name:"ID"}];
      int64 value = 2 [(tableau.field) = {name:"Value"}];
    }
  }
}
ItemConf.json
{
    "itemList": [
        {
            "id": 1,
            "name": "Apple",
            "prop": {
                "id": 1,
                "value": "10"
            }
        },
        {
            "id": 2,
            "name": "Orange",
            "prop": {
                "id": 2,
                "value": "20"
            }
        },
        {
            "id": 3,
            "name": "Banana",
            "prop": null
        }
    ]
}

Incell-struct in vertical-list

A worksheet ItemConf in HelloWorld.xlsx:

IDNamePropID
[Item]uint32string{int32 ID,int64 Value}Prop
Item’s IDItem’s nameProp’s ID
1Apple1,100
2Orange2,200
3Banana

Generated:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx"};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf" namerow:1 typerow:2 noterow:3 datarow:4};

  repeated Item item_list = 1 [(tableau.field) = {layout:LAYOUT_VERTICAL}];
  message Item {
    uint32 id = 1 [(tableau.field) = {name:"ID"}];
    string name = 2 [(tableau.field) = {name:"Name"}];
    Prop prop_id = 3 [(tableau.field) = {name:"PropID" span:SPAN_INNER_CELL}];
    message Prop {
      int32 id = 1 [(tableau.field) = {name:"ID"}];
      int64 value = 2 [(tableau.field) = {name:"Value"}];
    }
  }
}
ItemConf.json
{
    "itemList": [
        {
            "id": 1,
            "name": "Apple",
            "propId": {
                "id": 1,
                "value": "100"
            }
        },
        {
            "id": 2,
            "name": "Orange",
            "propId": {
                "id": 2,
                "value": "200"
            }
        },
        {
            "id": 3,
            "name": "Banana",
            "propId": null
        }
    ]
}

First-field in horizontal-list

Struct in horizontal-list

A worksheet ItemConf in HelloWorld.xlsx:

Reward1ItemIDReward1ItemNumReward1NameReward2ItemIDReward2ItemNumReward2Name
[Reward]{Item}int32int32stringint32int32string
Item1’s IDItem1’s numReward’s nameItem1’s IDItem1’s numReward’s name
110Lotto10100Super Lotto

Generated:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx"};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf" namerow:1 typerow:2 noterow:3 datarow:4};

  repeated Reward reward_list = 1 [(tableau.field) = {name:"Reward" layout:LAYOUT_HORIZONTAL}];
  message Reward {
    Item item = 1 [(tableau.field) = {name:"Item"}];
    message Item {
      int32 id = 1 [(tableau.field) = {name:"ID"}];
      int32 num = 2 [(tableau.field) = {name:"Num"}];
    }
    string name = 2 [(tableau.field) = {name:"Name"}];
  }
}
ItemConf.json
{
    "rewardList": [
        {
            "item": {
                "id": 1,
                "num": 10
            },
            "name": "Lotto"
        },
        {
            "item": {
                "id": 10,
                "num": 100
            },
            "name": "Super Lotto"
        }
    ]
}

Predefined-struct in horizontal-list

Item in common.proto is predefined as:

message Item {
    int32 id = 1 [(tableau.field) = {name:"ID"}];
    int32 num = 2 [(tableau.field) = {name:"Num"}];
}

A worksheet ItemConf in HelloWorld.xlsx:

Reward1ItemIDReward1ItemNumReward1NameReward2ItemIDReward2ItemNumReward2Name
[Reward]{.Item}int32int32stringint32int32string
Item1’s IDItem1’s numReward’s nameItem1’s IDItem1’s numReward’s name
110Lotto10100Super Lotto

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

  repeated Reward reward_list = 1 [(tableau.field) = {name:"Reward" layout:LAYOUT_HORIZONTAL}];
  message Reward {
    protoconf.Item item = 1 [(tableau.field) = {name:"Item"}];
    string name = 2 [(tableau.field) = {name:"Name"}];
  }
}
ItemConf.json
{
    "rewardList": [
        {
            "item": {
                "id": 1,
                "num": 10
            },
            "name": "Lotto"
        },
        {
            "item": {
                "id": 10,
                "num": 100
            },
            "name": "Super Lotto"
        }
    ]
}

Incell-struct in horizontal-list

A worksheet ItemConf in HelloWorld.xlsx:

Reward1ItemReward1NameReward2ItemReward2Name
[Reward]{int32 ID, int32 Num}ItemstringItemstring
Reward1’s itemReward’s nameReward2’s itemReward’s name
1,10Lotto2,20Super Lotto

Generated:

hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx"};

message ItemConf {
  option (tableau.worksheet) = {name:"ItemConf" namerow:1 typerow:2 noterow:3 datarow:4};

  repeated Item item_list = 1 [(tableau.field) = {layout:LAYOUT_VERTICAL}];
  message Item {
    uint32 id = 1 [(tableau.field) = {name:"ID"}];
    string name = 2 [(tableau.field) = {name:"Name"}];
    Prop prop_id = 3 [(tableau.field) = {name:"PropID" span:SPAN_INNER_CELL}];
    message Prop {
      int32 id = 1 [(tableau.field) = {name:"ID"}];
      int64 value = 2 [(tableau.field) = {name:"Value"}];
    }
  }
}
ItemConf.json
{
    "rewardList": [
        {
            "item": {
                "id": 1,
                "num": 10
            },
            "name": "Lotto"
        },
        {
            "item": {
                "id": 2,
                "num": 20
            },
            "name": "Super Lotto"
        }
    ]
}