Skip to content

Commit 394be00

Browse files
committed
docs: improve merger description and sync zh docs for metasheet
1 parent 43d4885 commit 394be00

2 files changed

Lines changed: 218 additions & 2 deletions

File tree

content/en/docs/excel/metasheet.md

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,13 @@ Each element can be:
225225

226226
{{< alert icon="ⓘ" context="info" text="Glob pattern usually should not match the main workbook. If matched, then tableauc will auto eliminate it." />}}
227227

228-
For example:
228+
### Merging multiple workbooks
229+
230+
For example, there are three workbooks, each containing a worksheet `ZoneConf` with the same schema:
231+
232+
- **MergerMain.xlsx** (main): contains `@TABLEAU` metasheet with a Glob pattern `Merger*.xlsx` in the `Merger` column to match all sub workbooks.
233+
- **Merger2.xlsx** (sub): contains only the data worksheet, no `@TABLEAU` metasheet needed.
234+
- **Merger3.xlsx** (sub): contains only the data worksheet, no `@TABLEAU` metasheet needed.
229235

230236
The first (main) workbook: a worksheet `ZoneConf` in *MergerMain.xlsx* (with `@TABLEAU`):
231237

@@ -331,6 +337,108 @@ message ZoneConf {
331337

332338
{{< /details >}}
333339

340+
### Merging multiple sheets in same workbook
341+
342+
For example, there are three worksheets with the same schema in the same workbook *Merger.xlsx*:
343+
344+
- `ZoneConf` (main sheet, with `@TABLEAU`)
345+
- `ZoneConf2` (sub sheet)
346+
- `ZoneConf3` (sub sheet)
347+
348+
The main workbook: worksheets `ZoneConf`, `ZoneConf2`, `ZoneConf3`, and `@TABLEAU` in *Merger.xlsx*:
349+
350+
{{< spreadsheet "Merger.xlsx" ZoneConf ZoneConf2 ZoneConf3 "@TABLEAU" >}}
351+
352+
{{< sheet colored>}}
353+
354+
| ID | Name | Difficulty |
355+
| ----------------- | ----------- | ----------------- |
356+
| map<uint32, Zone> | string | int32 |
357+
| Zone's ID | Zone's name | Zone's difficulty |
358+
| 1 | Infinity | 100 |
359+
360+
{{< /sheet >}}
361+
362+
{{< sheet colored>}}
363+
364+
| ID | Name | Difficulty |
365+
| ----------------- | ----------- | ----------------- |
366+
| map<uint32, Zone> | string | int32 |
367+
| Zone's ID | Zone's name | Zone's difficulty |
368+
| 2 | Desert | 200 |
369+
370+
{{< /sheet >}}
371+
372+
{{< sheet colored>}}
373+
374+
| ID | Name | Difficulty |
375+
| ----------------- | ----------- | ----------------- |
376+
| map<uint32, Zone> | string | int32 |
377+
| Zone's ID | Zone's name | Zone's difficulty |
378+
| 3 | Snowfield | 300 |
379+
380+
{{< /sheet >}}
381+
382+
{{< sheet colored1 >}}
383+
384+
| Sheet | Merger |
385+
| -------- | ------------------------------------------- |
386+
| ZoneConf | Merger.xlsx#ZoneConf2,Merger.xlsx#ZoneConf3 |
387+
388+
{{< /sheet >}}
389+
390+
{{< /spreadsheet >}}
391+
392+
{{< alert icon="ⓘ" context="info" text="Use <code>&lt;Workbook&gt;#&lt;Worksheet&gt;</code> to refer to a specific sheet in a workbook." />}}
393+
394+
Generated:
395+
396+
{{< details "merger_same.proto" open >}}
397+
398+
```protobuf
399+
// --snip--
400+
option (tableau.workbook) = {name:"Merger.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
401+
402+
message ZoneConf {
403+
option (tableau.worksheet) = {name:"ZoneConf" merger:"Merger.xlsx#ZoneConf2,Merger.xlsx#ZoneConf3"};
404+
405+
map<uint32, Zone> zone_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
406+
message Zone {
407+
uint32 id = 1 [(tableau.field) = {name:"ID"}];
408+
string name = 2 [(tableau.field) = {name:"Name"}];
409+
int32 difficulty = 3 [(tableau.field) = {name:"Difficulty"}];
410+
}
411+
}
412+
```
413+
414+
{{< /details >}}
415+
416+
{{< details "ZoneConf.json" >}}
417+
418+
```json
419+
{
420+
"zoneMap": {
421+
"1": {
422+
"id": 1,
423+
"name": "Infinity",
424+
"difficulty": 100
425+
},
426+
"2": {
427+
"id": 2,
428+
"name": "Desert",
429+
"difficulty": 200
430+
},
431+
"3": {
432+
"id": 3,
433+
"name": "Snowfield",
434+
"difficulty": 300
435+
}
436+
}
437+
}
438+
```
439+
440+
{{< /details >}}
441+
334442
## Option `Scatter`
335443

336444
Option `Scatter` is used to scatter multiple sheets (comma-separated) with same schema to different generated config files.

content/zh/docs/excel/metasheet.md

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ message HeroConf {
219219

220220
{{< alert icon="ⓘ" context="info" text="Glob 模式通常不应匹配主 workbook。如果匹配,tableauc 会自动排除它。" />}}
221221

222-
例如:
222+
### 合并多个 workbook
223+
224+
例如,有三个 workbook,每个都包含一个具有相同 schema 的 worksheet `ZoneConf`
225+
226+
- **MergerMain.xlsx**(主):包含 `@TABLEAU` metasheet,在 `Merger` 列中使用 Glob 模式 `Merger*.xlsx` 匹配所有子 workbook。
227+
- **Merger2.xlsx**(子):仅包含数据 worksheet,无需 `@TABLEAU` metasheet。
228+
- **Merger3.xlsx**(子):仅包含数据 worksheet,无需 `@TABLEAU` metasheet。
223229

224230
第一个(主)workbook:*MergerMain.xlsx* 中的 worksheet `ZoneConf`(含 `@TABLEAU`):
225231

@@ -313,6 +319,108 @@ message ZoneConf {
313319

314320
{{< /details >}}
315321

322+
### 合并同一 workbook 中的多个 sheet
323+
324+
例如,同一 workbook *Merger.xlsx* 中有三个具有相同 schema 的 worksheet:
325+
326+
- `ZoneConf`(主 sheet,含 `@TABLEAU`
327+
- `ZoneConf2`(子 sheet)
328+
- `ZoneConf3`(子 sheet)
329+
330+
主(也是唯一的)workbook:*Merger.xlsx* 中的 worksheet `ZoneConf``ZoneConf2``ZoneConf3``@TABLEAU`
331+
332+
{{< spreadsheet "Merger.xlsx" ZoneConf ZoneConf2 ZoneConf3 "@TABLEAU" >}}
333+
334+
{{< sheet colored>}}
335+
336+
| ID | Name | Difficulty |
337+
| ----------------- | ----------- | ----------------- |
338+
| map<uint32, Zone> | string | int32 |
339+
| Zone's ID | Zone's name | Zone's difficulty |
340+
| 1 | Infinity | 100 |
341+
342+
{{< /sheet >}}
343+
344+
{{< sheet colored>}}
345+
346+
| ID | Name | Difficulty |
347+
| ----------------- | ----------- | ----------------- |
348+
| map<uint32, Zone> | string | int32 |
349+
| Zone's ID | Zone's name | Zone's difficulty |
350+
| 2 | Desert | 200 |
351+
352+
{{< /sheet >}}
353+
354+
{{< sheet colored>}}
355+
356+
| ID | Name | Difficulty |
357+
| ----------------- | ----------- | ----------------- |
358+
| map<uint32, Zone> | string | int32 |
359+
| Zone's ID | Zone's name | Zone's difficulty |
360+
| 3 | Snowfield | 300 |
361+
362+
{{< /sheet >}}
363+
364+
{{< sheet colored1 >}}
365+
366+
| Sheet | Merger |
367+
| -------- | ------------------------------------------- |
368+
| ZoneConf | Merger.xlsx#ZoneConf2,Merger.xlsx#ZoneConf3 |
369+
370+
{{< /sheet >}}
371+
372+
{{< /spreadsheet >}}
373+
374+
{{< alert icon="ⓘ" context="info" text="使用 <code>&lt;Workbook&gt;#&lt;Worksheet&gt;</code> 引用 workbook 中的特定 sheet。" />}}
375+
376+
生成结果:
377+
378+
{{< details "merger_same.proto" open >}}
379+
380+
```protobuf
381+
// --snip--
382+
option (tableau.workbook) = {name:"Merger.xlsx" namerow:1 typerow:2 noterow:3 datarow:4};
383+
384+
message ZoneConf {
385+
option (tableau.worksheet) = {name:"ZoneConf" merger:"Merger.xlsx#ZoneConf2,Merger.xlsx#ZoneConf3"};
386+
387+
map<uint32, Zone> zone_map = 1 [(tableau.field) = {key:"ID" layout:LAYOUT_VERTICAL}];
388+
message Zone {
389+
uint32 id = 1 [(tableau.field) = {name:"ID"}];
390+
string name = 2 [(tableau.field) = {name:"Name"}];
391+
int32 difficulty = 3 [(tableau.field) = {name:"Difficulty"}];
392+
}
393+
}
394+
```
395+
396+
{{< /details >}}
397+
398+
{{< details "ZoneConf.json" >}}
399+
400+
```json
401+
{
402+
"zoneMap": {
403+
"1": {
404+
"id": 1,
405+
"name": "Infinity",
406+
"difficulty": 100
407+
},
408+
"2": {
409+
"id": 2,
410+
"name": "Desert",
411+
"difficulty": 200
412+
},
413+
"3": {
414+
"id": 3,
415+
"name": "Snowfield",
416+
"difficulty": 300
417+
}
418+
}
419+
}
420+
```
421+
422+
{{< /details >}}
423+
316424
## 选项 `Scatter`
317425

318426
`Scatter` 选项用于将多个具有相同 schema 的 sheet(逗号分隔)分别转换为不同的配置文件。

0 commit comments

Comments
 (0)