Struct in map

The nesting specification of struct in map.

Nested in vertical-map

Struct in vertical-map

A worksheet ItemConf in HelloWorld.xlsx:

IDItemIDItemNum
map<int32, Reward>{Item}int32int32
Reward’s IDItem’s IDItem’s Num
1110
2220
3

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

  map<int32, Reward> reward_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
  message Reward {
    int32 id = 1 [(tableau.field) = {name:"ID"}];
    Item item = 2 [(tableau.field) = {name:"Item"}];
    message Item {
      int32 id = 1 [(tableau.field) = {name:"ID"}];
      int32 num = 2 [(tableau.field) = {name:"Num"}];
    }
  }
}
ItemConf.json
{
    "rewardMap": {
        "1": {
            "id": 1,
            "item": {
                "id": 1,
                "num": 10
            }
        },
        "2": {
            "id": 2,
            "item": {
                "id": 2,
                "num": 20
            }
        },
        "3": {
            "id": 3,
            "item": null
        }
    }
}

Predefined-struct in vertical-map

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:

IDItemIDItemNum
map<int32, Reward>{.Item}int32int32
Reward’s IDItem’s IDItem’s Num
1110
2220
3

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<int32, Reward> reward_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
  message Reward {
    int32 id = 1 [(tableau.field) = {name:"ID"}];
    protoconf.Item item = 2 [(tableau.field) = {name:"Item"}];
  }
}
ItemConf.json
{
    "rewardMap": {
        "1": {
            "id": 1,
            "item": {
                "id": 1,
                "num": 10
            }
        },
        "2": {
            "id": 2,
            "item": {
                "id": 2,
                "num": 20
            }
        },
        "3": {
            "id": 3,
            "item": null
        }
    }
}

Incell-struct in vertical-map

A worksheet ItemConf in HelloWorld.xlsx:

IDItem
map<int32, Reward>{int32 ID, int32 Num}Item
Reward’s IDItem’s info
11,100
22,200
3

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

  map<int32, Reward> reward_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
  message Reward {
    int32 id = 1 [(tableau.field) = {name:"ID"}];
    Item item = 2 [(tableau.field) = {name:"Item" span:SPAN_INNER_CELL}];
    message Item {
      int32 id = 1 [(tableau.field) = {name:"ID"}];
      int32 num = 2 [(tableau.field) = {name:"Num"}];
    }
  }
}
ItemConf.json
{
    "rewardMap": {
        "1": {
            "id": 1,
            "item": {
                "id": 1,
                "num": 100
            }
        },
        "2": {
            "id": 2,
            "item": {
                "id": 2,
                "num": 200
            }
        },
        "3": {
            "id": 3,
            "item": null
        }
    }
}