Repository navigation
fix(pptx): preserve date-axis category labels - #2734
他们都不玩了 (shuaiyafei) wants to merge 2 commits into
Conversation
Guillermo Dols (gdols)
left a comment
There was a problem hiding this comment.
Ran tests/test_pptx.py here (59 passed) and pushed a few more values through _format_date_category: float noise in the time part comes out clean (45658.333333333336 gives 2025-01-01T08:00:00), the last Excel date 2958465 gives 9999-12-31, and anything past it, nan or inf keeps the original label.
One case it misses is a date axis switched to Text axis. To try it I took your 1900 fixture and renamed c:dateAx to c:catAx, dropping the time unit children. The categories are still a numRef with the yyyy\-mm\-dd format code, so a text axis should still show them as dates, but the output goes back to | 46023.0 | 100.0 |. I don't have PowerPoint here to confirm exactly what it writes when you change the axis type, so take that part with a grain of salt.
Checking the category formatCode instead of the axis element would cover both, and it would tie the check to the categories of plots[0], which are the ones being printed. As it is, a combo chart with a date axis on another plot would convert the first plot's labels too. Just a thought, I'd be fine with it going in as it is.
|
他们都不玩了 (@shuaiyafei) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Problem
A PowerPoint chart with a date axis exports its Excel serial numbers as category labels. For example, a monthly revenue chart with dates
2026-01-01and2026-02-01currently produces46023.0and46054.0. The Markdown loses the dates needed to interpret the time series.This was found through source analysis and reproduced with serialized PPTX files through the public Python API and CLI.
Change
Format date-axis categories as ISO dates, using the chart's declared 1900 or 1904 date system. Match the first plot's axis IDs before interpreting its categories as dates, so a date axis on a different plot cannot change numeric labels. Fractional days retain their time component. Ordinary numeric categories keep their values. Unparseable labels and Excel's fictitious February 29, 1900 retain their original text.
Reproduction
Before:
| 46023.0 | 100.0 |. After:| 2026-01-01 | 100.0 |.Verification
21d9c1dgive 2 failures for the date systems and 2 passing controls for numeric labels.python -m pytest packages/markitdown/tests/test_pptx.py -q: 61 passed.python -m markitdown <file.pptx>.pre-commit run --all-filesandgit diff --check: passed.Tested on macOS arm64 with Python 3.12.15 and python-pptx 1.0.2. The complete all-format suite and live OCR/LLM integrations were not run. Date-formatted numeric caches on Text axes are not covered by this change; PowerPoint UI behavior was not verified.
AI assistance: Codex helped investigate, implement, and validate this change.