feat(rest): Excel 导出 select/status 字段带颜色(白底+选项色作字体色) - #2761
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 7 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
Carry a select/radio option's `color` into the xlsx export as the cell font colour (white background), gated behind a 10k-row style cap that degrades to a colourless export (X-Export-Styles: dropped) above the cap. csv/json unchanged.
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.
Closes #2757
做了什么
Excel(xlsx)导出时,select / radio 字段单元格按其选项的
color上色——白底 + 选项色作字体色,让导出的表格观感对齐系统里的彩色徽章。CSV / JSON 导出不变。改动
packages/rest/src/export-format.tstoArgb():hex#RGB/#RRGGBB→ exceljs ARGBFFRRGGBB,非法(空/命名色/rgb()/长度不符)返回undefined。cellFontColor():取匹配选项的颜色;非 select/radio 字段、无匹配值、选项无 color、非法 hex 一律返回undefined(即不上色)。multiselect 明确排除(单元格单一字体色对多值有歧义)。ExportFieldMeta.options补color?。packages/rest/src/rest-server.tscreateXlsxStream(res, useStyles)加参,透传给 exceljsWorkbookWriter。effectiveLimit <= 10000时开样式并逐格设cell.font.color。数量限制(对齐大厂做法)
样式化导出比纯数据 dump 重,故设独立行数上限
STYLE_ROW_CAP = 10000:X-Export-Styles: appliedX-Export-Styles: dropped超阈值自动降级为无样式(仍拿到全部数据),而非直接报错。对齐 Salesforce「格式化导出上限低于纯数据导出」、ServiceNow 默认 1 万行 的行业做法。既有 5 万行硬顶不变。
测试
export-format.test.ts:toArgb/cellFontColor单测(3 位简写、6 位、非法、非 select、无 color 选项、multiselect 排除等)。export-integration.test.ts(真引擎 + 真 protocol):读回 xlsx 断言font.color.argb(#e11d48→FFE11D48、简写#3ab→FF33AABB),非选项列无色;limit=20000降级(无样式 +X-Export-Styles: dropped)。@objectstack/rest全量:227 passed。备注
cellFontColor处扩展即可。packages/rest/src/package-routes.ts有两处既有 TS 报错,与本 PR 无关。