[WC-3334] Fix DG2 export type bugs#2182
Conversation
b804adb to
05d8784
Compare
05d8784 to
bc6c7a0
Compare
| export interface ExcelCell { | ||
| /** Cell type: 's' = string, 'n' = number, 'd' = date */ | ||
| t: "s" | "n" | "d"; | ||
| /** Underlying value */ | ||
| v: string | number | Date; | ||
| /** Optional Excel number/date format, e.g. "yyyy-mm-dd" or "$0.00" */ | ||
| z?: string; | ||
| /** Optional pre-formatted display text */ | ||
| w?: string; | ||
| } | ||
|
|
There was a problem hiding this comment.
Can we use "proper" names? (e.g. type, value, format?
There was a problem hiding this comment.
Not if we want to keep it SheetJS compatible: https://docs.sheetjs.com/docs/csf/cell
| } | ||
|
|
||
| function hasTimeComponent(format: string): boolean { | ||
| return /[hs]/i.test(format); |
There was a problem hiding this comment.
Which format schema we use in number/date cases? Is there ISO spec or something?
There was a problem hiding this comment.
The z property follows ECMA-376 / OOXML number format strings, the same syntax Excel uses natively.
SheetJS reads them directly and applies them in the workbook.
Dates: yyyy, mm, dd, mmm, h, s tokens
e.g. "yyyy-mm-dd", "dd-mmm-yyyy hh:mm:ss"
Numbers: #, 0, ,, . tokens
e.g. "#,##0.00", "$0.00"
There's no ISO spec here; it's the Excel format code syntax defined in ECMA-376 Part 1, §18.8.31.
The hasTimeComponent regex /[hs]/i keys off h (hours) and s (seconds) from that same token set to decide whether to strip the time part before writing the date cell.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Documents current behavior of attribute, dynamicText, and customContent readers before bug-fix changes are applied. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…number Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…digits Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Remove "b" from ExcelCell.t union and boolean from ExcelCell.v since excelBoolean now returns string cells. Fix misleading test name for undefined dynamicText case. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
0a76230 to
4e940c2
Compare
Pull request type
Refactoring (e.g. file rename, variable rename, etc.)
Bug fix (non-breaking change which fixes an issue)
Description
Fix multiple data export bugs in DataGrid2's Excel export feature (WC-3334).
Problems
Changes
fallback on parse failure