Skip to content

Commit fb489c1

Browse files
committed
feat: add more examples for keyed-list
1 parent 021424d commit fb489c1

File tree

3 files changed

+262
-9
lines changed

3 files changed

+262
-9
lines changed

content/en/docs/excel/field-property.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ toc: true
3636

3737
Option `unique` can be specified as `true` or `false` in the field property. It can check the uniqueness of any scalar field in list/map element.
3838

39-
- If you set `unique` to `true` explicitly, then tableau will report an error if a duplicate key is appeared.
39+
- If you set `unique` to `true` explicitly, tableau will report an error if a duplicate key appears.
4040
- If you set `unique` to `false` explicitly, no check will be performed.
4141

4242
### Map (or KeyedList) key

content/en/docs/excel/list-in-list.md

Lines changed: 254 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,97 @@ message ItemConf {
199199

200200
{{< /details >}}
201201

202+
### Vertical-keyed-list in vertical-keyed-list
203+
204+
A worksheet `ItemConf` in *HelloWorld.xlsx*:
205+
206+
{{< spreadsheet "HelloWorld.xlsx" ItemConf "@TABLEAU" >}}
207+
208+
{{< sheet colored >}}
209+
210+
| ID | Desc | PropID | PropNum |
211+
| --------------------- | ----------- | ---------------- | ---------- |
212+
| [KeyedItem]\<uint32\> | string | [Prop]\<uint32\> | int32 |
213+
| Item's ID | Item's desc | Prop's ID | Prop's num |
214+
| 1 | Apple | 10 | 100 |
215+
| 1 | Banana | 11 | 110 |
216+
| 2 | Orange | 20 | 200 |
217+
218+
{{< /sheet >}}
219+
220+
{{< sheet >}}
221+
222+
| | | |
223+
| --- | --- | --- |
224+
| | | |
225+
| | | |
226+
| | | |
227+
228+
{{< /sheet >}}
229+
230+
{{< /spreadsheet >}}
231+
232+
Generated:
233+
234+
{{< details "hello_world.proto" >}}
235+
236+
```protobuf
237+
// --snip--
238+
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
239+
240+
message ItemConf {
241+
option (tableau.worksheet) = {name:"ItemConf"};
242+
243+
repeated KeyedItem keyed_item_list = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
244+
message KeyedItem {
245+
uint32 id = 1 [(tableau.field) = {name:"ID"}];
246+
string desc = 2 [(tableau.field) = {name:"Desc"}];
247+
repeated Prop prop_list = 3 [(tableau.field) = {key:"PropID" layout:LAYOUT_VERTICAL}];
248+
message Prop {
249+
uint32 prop_id = 1 [(tableau.field) = {name:"PropID"}];
250+
int32 prop_num = 2 [(tableau.field) = {name:"PropNum"}];
251+
}
252+
}
253+
}
254+
```
255+
256+
{{< /details >}}
257+
258+
{{< details "ItemConf.json" >}}
259+
260+
```json
261+
{
262+
"keyedItemList": [
263+
{
264+
"id": 1,
265+
"desc": "Apple",
266+
"propList": [
267+
{
268+
"propId": 10,
269+
"propNum": 100
270+
},
271+
{
272+
"propId": 11,
273+
"propNum": 110
274+
}
275+
]
276+
},
277+
{
278+
"id": 2,
279+
"desc": "Orange",
280+
"propList": [
281+
{
282+
"propId": 20,
283+
"propNum": 200
284+
}
285+
]
286+
}
287+
]
288+
}
289+
```
290+
291+
{{< /details >}}
292+
202293
### Incell-list in vertical-keyed-list
203294

204295
A worksheet `ItemConf` in *HelloWorld.xlsx*:
@@ -282,7 +373,91 @@ message ItemConf {
282373

283374
{{< /details >}}
284375

285-
## First-field in horizontal-list
376+
### Incell-keyed-list in vertical-keyed-list
377+
378+
A worksheet `ItemConf` in *HelloWorld.xlsx*:
379+
380+
{{< spreadsheet "HelloWorld.xlsx" ItemConf "@TABLEAU" >}}
381+
382+
{{< sheet colored >}}
383+
384+
| ID | Desc | Tip |
385+
| ------------------------------------- | ----------- | ------------ |
386+
| [KeyedItem]\<uint32\>\|{unique:false} | string | []\<uint32\> |
387+
| Item's ID | Item's desc | Item's tip |
388+
| 1 | Apple | 1,2,3 |
389+
| 1 | Banana | 4,5 |
390+
| 2 | Orange | 1,2 |
391+
392+
{{< /sheet >}}
393+
394+
{{< sheet >}}
395+
396+
| | | |
397+
| --- | --- | --- |
398+
| | | |
399+
| | | |
400+
| | | |
401+
402+
{{< /sheet >}}
403+
404+
{{< /spreadsheet >}}
405+
406+
We want the parent struct keyed-list to aggreate incell keyed-list, so need to set the field property `unique` to `false`.
407+
408+
Generated:
409+
410+
{{< details "hello_world.proto" >}}
411+
412+
```protobuf
413+
// --snip--
414+
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
415+
416+
message ItemConf {
417+
option (tableau.worksheet) = {name:"ItemConf"};
418+
419+
repeated KeyedItem keyed_item_list = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
420+
message KeyedItem {
421+
uint32 id = 1 [(tableau.field) = {name:"ID" prop:{unique:false}}];
422+
string desc = 2 [(tableau.field) = {name:"Desc"}];
423+
repeated uint32 tip_list = 3 [(tableau.field) = {name:"Tip" key:"Tip" layout:LAYOUT_INCELL}];
424+
}
425+
}
426+
```
427+
428+
{{< /details >}}
429+
430+
{{< details "ItemConf.json" >}}
431+
432+
```json
433+
{
434+
"keyedItemList": [
435+
{
436+
"id": 1,
437+
"desc": "Apple",
438+
"tipList": [
439+
1,
440+
2,
441+
3,
442+
4,
443+
5
444+
]
445+
},
446+
{
447+
"id": 2,
448+
"desc": "Orange",
449+
"tipList": [
450+
1,
451+
2
452+
]
453+
}
454+
]
455+
}
456+
```
457+
458+
{{< /details >}}
459+
460+
## Nested in horizontal-list
286461

287462
### Horizontal-list in horizontal-list
288463

@@ -461,3 +636,81 @@ message ItemConf {
461636
```
462637

463638
{{< /details >}}
639+
640+
### Incell-list in horizontal-list
641+
642+
A worksheet `ItemConf` in *HelloWorld.xlsx*:
643+
644+
{{< spreadsheet "HelloWorld.xlsx" ItemConf "@TABLEAU" >}}
645+
646+
{{< sheet colored >}}
647+
648+
| Task1Param | Task2Param | Task3Param |
649+
| ------------- | ---------- | ---------- |
650+
| [Task][]int32 | []int32 | []int32 |
651+
| Task1 | Task2 | Task3 |
652+
| 1,2 | 3,4 | 5,6,7 |
653+
654+
{{< /sheet >}}
655+
656+
{{< sheet >}}
657+
658+
| | | |
659+
| --- | --- | --- |
660+
| | | |
661+
| | | |
662+
| | | |
663+
664+
{{< /sheet >}}
665+
666+
{{< /spreadsheet >}}
667+
668+
Generated:
669+
670+
{{< details "hello_world.proto" >}}
671+
672+
```protobuf
673+
// --snip--
674+
option (tableau.workbook) = {name:"HelloWorld.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
675+
676+
message ItemConf {
677+
option (tableau.worksheet) = {name:"ItemConf"};
678+
679+
repeated Task task_list = 1 [(tableau.field) = {name:"Task" layout:LAYOUT_HORIZONTAL}];
680+
message Task {
681+
repeated int32 param_list = 1 [(tableau.field) = {name:"Param" layout:LAYOUT_INCELL}];
682+
}
683+
}
684+
```
685+
686+
{{< /details >}}
687+
688+
{{< details "ItemConf.json" >}}
689+
690+
```json
691+
{
692+
"taskList": [
693+
{
694+
"paramList": [
695+
1,
696+
2
697+
]
698+
},
699+
{
700+
"paramList": [
701+
3,
702+
4
703+
]
704+
},
705+
{
706+
"paramList": [
707+
5,
708+
6,
709+
7
710+
]
711+
}
712+
]
713+
}
714+
```
715+
716+
{{< /details >}}

content/en/docs/excel/metasheet.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -544,33 +544,33 @@ Example: two worksheets *ItemConf* and *ShopConf* in HelloWorld.xlsx:
544544

545545
### Single-column index
546546

547-
Format: `Column<ColumnX,ColumnY,...>[@IndexName]`.
547+
Format: `Column<ColumnX,ColumnY,...>@IndexName`.
548548

549549
The sign `@` is the separator between column name and index name. if `IndexName` is not set, it will be this column’s parent struct type name. One or more indexes can be specified by comma-separated rule. The columns in the angle brackets `<>` specify the sorting columns which the index sort by.
550550

551551
Examples:
552552

553553
- `ID`
554554
- `ID@Item`
555-
- `ID<ID>@Item`: sort index by ID
556-
- `ID<Type,Priority>@Item`: sort index by Type and Priority
555+
- `ID<ID>@Item`: sort index by ID.
556+
- `ID<Type,Priority>@Item`: sort index by Type and Priority.
557557
- `ID, Name@AwardItem`
558558
- `ID@Item, Name@AwardItem`
559559

560560
### Multi-column index
561561

562-
Format: ``.
562+
Format: `(Column1,Column2,...)<ColumnX,ColumnY,...>@IndexName`.
563563

564564
Multi-column index (or composite index) is composed of **multiple columns in the same struct** (in list or map) to increase query speed.
565565

566566
The sign `@` is the separator between enclosed column names by parentheses and index name. if `IndexName` is not set, it will be this column’s parent struct type name. One or more indexes can be specified by comma-separated rule. The columns in the angle brackets `<>` specify the sorting columns which the index sort by.
567567

568568
Examples:
569569

570-
- `(ID,Name)`
570+
- `(ID,Name)`: index name not set, then determined by parent struct type name.
571571
- `(ID,Name)@AwardItem`
572-
- `(ID,Name)<ID>@AwardItem`: sort index by ID
573-
- `(ID,Type)<Type,Priority>@Item`: sort index by Type and Priority
572+
- `(ID,Name)<ID>`: sort index by ID.
573+
- `(ID,Type)<Type,Priority>@Item`: sort index by Type and Priority.
574574
- `ID@Item, (ID,Name)@AwardItem`: one single-column index and one multi-column index.
575575

576576
## Option `Patch`

0 commit comments

Comments
 (0)