Skip to main content
Version: Next

Excel Basic Header Conventions

This page covers: which sheets Luban treats as valid data tables, and how to fill basic types, enums, and nullable fields.

In one sentence

Mark headers in A1 (or the title area) with ## / ##var / ##type, etc.; data rows follow. Sheets whose A1 does not start with ## are ignored.

Supported files

xls / xlsx / xlsm / csv, and more. You can also use sheetName@file.xlsx to read only one sheet.

For CSV files not in GBK or UTF-8, Luban guesses encoding automatically; you usually do not need to specify it.

xlsx reads all sheets, but sheets whose A1 does not start with ## are ignored (use those for non-data notes).

Minimal complete example

Assume the row record type is Item, with fields id / name / price / on_sale:

##varidnamepriceon_sale#备注
##typeintstringintbool
##groupc,scc
##道具ID名称价格是否上架策划备注列
1001金币0基础货币
1002药水50true
##1003草稿1本行是注释行,不导出

Key points:

Row/columnRole
##var (or first cell ##)Field-name row
##typeType row
##groupExport groups: c client, s server, empty = all targets
## / ##commentComment row; can also hold Chinese field descriptions
Field name starts with # or is emptyComment column, not exported
Data row whose first column starts with ##Comment row, entire row not exported

##xxx row order can vary; ##group and comment rows are optional. Prefer field names like xx_yy_zz; generation converts them to Pascal/camel case per language.

Filling basic types

##varidflagratiotitleopen_time
##typeintboolfloatstringdatetime
11.5hello2024-01-01 12:00:00
202024-06-01
3True0""
TypeValid valuesNotes
booltrue/false/0/1// (case-insensitive)Other values error
Integer / floatNumbers; column/column-constraint mode allows empty defaultsIn stream/sep, must fill 0 explicitly
stringEmpty cell = empty stringIn stream format, empty string needs ""
string#escape=1Supports converting \n to newlines
datetimeExcel date, or yyyy-mm-dd hh:mm:ss / yyyy-mm-dd hh:mm / yyyy-mm-dd hh / yyyy-mm-ddGenerally do not leave empty; missing time parts default to 0

primitive types

Enums

You can fill: enum name, alias, or integer value. Flags enums can use A|B (change separator via enum sep, e.g. sep=","A,B).

Flags column-constraint mode (enum must be flags): use enum item names as child columns; fill 1/non-empty to include that flag; result is bitwise OR of all non-zero/non-empty items. See Nested structures.

enum

##varidquality
##typeintQuality
1WHITE
2
31
4

If the enum has an item with value 0, you may leave the cell empty for that item; otherwise leaving it empty errors.

Nullable types

Except for containers, use T?. All of them accept null for empty.

##varidcountdescpos
##typeintint?string?vector2?
110hello{}1,2
2null
3null""
TypeHow to express empty
Atomic types like int?Leave empty or null
string?Leave empty = null; for empty string fill ""
Non-polymorphic bean?When non-null, must start with {} then fill fields; empty with null/leave blank
Polymorphic beanFollow polymorphism rules; see Polymorphism

nullable types

Table mode examples (with Schema)

Need__tables__ / XML essentialsData table shape
Ordinary id tableindex=id, mode empty or mapOne record per row, with a primary-key column
List without primary keymode=list, index emptyList only, no Get(id)
Composite primary keyindex=key1+key2Multiple columns unique together
Independent multi-indexindex=key1,key2Multiple independent unique keys
Global singletonmode=oneUsually one row; can use vertical tables
<table name="TbItem" value="Item" index="id" input="item.xlsx"/>
<table name="TbNotKeyList" value="NotKeyList" mode="list" input="not_key_list.xlsx"/>
<table name="TbUnion" value="UnionRow" index="key1+key2" input="union.xlsx"/>

File organization

input formMeaning
item.xlsxRead all valid sheets in the file
Bag@item.xlsxRead only the sheet named Bag
a.xlsx,b.xlsxMerge multiple files into one logical table
xlsx_dirRead files under a directory

Tables must be declared in Schema; see Add a table.

Common pitfalls

  • Sheet A1 does not start with ## → the whole sheet is skipped.
  • Created an xlsx but forgot to register it in __tables__.
  • Filled values in a comment column and wondered why they were not exported.
  • Left datetime empty and parsing failed.