feat: add -sp flag to skip sheets without A1-cell marker#8
Merged
Conversation
Add optional `sheetNameMarker` parameter to `GenerateFile` / `GenerateExcel`. When non-empty: - Only sheets whose names start with the marker are processed. - The marker prefix (plus any leading `_`, `-`, or space) is stripped from the sheet name before it becomes the generated class name. e.g. marker="DTGen", sheet="DTGenHeroConfig" → class "HeroConfig" This lets projects keep many auxiliary sheets (enums, text tables, reference data) in the same workbook without polluting the code-gen output. Sheets without the marker are silently skipped rather than generating a parse error.
Both ExportAll (default command) and ExportOne (data command) now accept `-sp <marker>`. When provided, only sheets whose names start with the marker are exported, and the marker is stripped when generating the class name.
Previously the -sp marker was matched against the sheet NAME, which required renaming sheets (e.g. "导出" → "DTGenHeroConfig"). This is incompatible with existing naming conventions. New behaviour: when -sp <marker> is provided, ValidSheet checks the value of the first cell in the first physical row (A1). If that value does not start with the marker, the sheet is silently skipped. - Sheet names and generated class names are unchanged - The marker cell (A1) already exists in the sheet — no schema changes - Sheets without the marker (text tables, enum refs, history tabs, etc.) are skipped without causing FormatException errors
After ParseSheetInfoRow, if DataSetType is still empty (meaning DTGen= was never set in A1), CreateGenerationContext returns immediately. This prevents RowTableParser from throwing FormatException on non-DataTables sheets like text tables, enum refs, etc. The -sp CLI flag is now redundant and will be removed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
xlsm 文件内通常含多个 Sheet(策划注释表、文本表、枚举参考表等),这些非 DataTables 格式的 Sheet 被尝试解析时会抛出
FormatException: 数据列名称不合法。解决方案
新增
-sp <marker>CLI 参数。逻辑:过滤依据:Sheet 的第一行第一个单元格(A1) 的值是否以
marker开头。关键约束:
SheetName决定)不做任何剥离或修改DTGen),其余 Sheet 无需改名用法示例
变更范围
DataTableGenerator.cs:ValidSheet方法改为检查 A1 单元格;移除旧的 Sheet 名前缀剥离代码Program.cs:更新-sp参数的 XML 文档注释