Map 嵌套 Struct
Excel map 中嵌套 struct 的规范说明。
纵向 map 中的嵌套
纵向 map 中的 struct
HelloWorld.xlsx 中的 worksheet ItemConf:
| ID | ItemID | ItemNum |
|---|---|---|
| map<int32, Reward> | {Item}int32 | int32 |
| Reward’s ID | Item’s ID | Item’s Num |
| 1 | 1 | 10 |
| 2 | 2 | 20 |
| 3 |
生成结果:
hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
message ItemConf {
option (tableau.worksheet) = {name:"ItemConf"};
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}
}
}
纵向 map 中的 predefined struct
common.proto 中预定义的 Item:
message Item {
int32 id = 1 [(tableau.field) = {name:"ID"}];
int32 num = 2 [(tableau.field) = {name:"Num"}];
}
HelloWorld.xlsx 中的 worksheet ItemConf:
| ID | ItemID | ItemNum |
|---|---|---|
| map<int32, Reward> | {.Item}int32 | int32 |
| Reward’s ID | Item’s ID | Item’s Num |
| 1 | 1 | 10 |
| 2 | 2 | 20 |
| 3 |
生成结果:
hello_world.proto
// --snip--
import "common.proto";
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
message ItemConf {
option (tableau.worksheet) = {name:"ItemConf"};
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}
}
}
纵向 map 中的 incell struct
HelloWorld.xlsx 中的 worksheet ItemConf:
| ID | Item |
|---|---|
| map<int32, Reward> | {int32 ID, int32 Num}Item |
| Reward’s ID | Item’s info |
| 1 | 1,100 |
| 2 | 2,200 |
| 3 |
生成结果:
hello_world.proto
// --snip--
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
message ItemConf {
option (tableau.worksheet) = {name:"ItemConf"};
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}
}
}