fix(harness): export each Excel GT sheet as its own PDF - #708
Merged
Conversation
Excel's AppleScript `save as` is a workbook-level command: applied to a worksheet it still delegates to the parent workbook's SaveAs, and a PDF SaveAs always exports every visible sheet. The per-sheet loop in export_excel_pdfs.applescript therefore wrote N whole-workbook copies, and public_visual_audit.rs concatenated them with pdfunite — every multi-sheet GT page count and text baseline was inflated by the sheet count (issue #616 measured a 10-sheet workbook exporting 230 GT pages for a real 23). Hiding every other visible sheet around each save is the only way to scope the export: PDF SaveAs skips hidden sheets. hideOtherVisibleSheets walks `every sheet` (chart sheets included), matches by name, flips only currently-visible sheets, and restoreSheetVisibility puts exactly those back before the next iteration's visibility check. Hidden and very- hidden sheets are never touched, and the workbook is open read-only and closed `saving no`, so nothing persists. Verified against the 10-sheet repository workbook through real Excel: ten per-sheet PDFs with page counts 1,5,3,1,1,6,1,2,1,2 summing to the workbook's true 23 pages, each holding its own sheet's content. Structure-protected workbooks now fail loudly at the first hide instead of silently producing duplicated GT — the correct trade for a ground- truth exporter. Related: #616 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Yonghye Kwon <developer.0hye@gmail.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.
What changed
scripts/macos/export_excel_pdfs.applescriptnow hides every other visible sheet (chart sheets included) around each per-sheetsave as, then restores exactly the sheets it hid, so each<id>-sheet-NNNN.pdfcontains exactly one worksheet.Why
Excel's AppleScript
save asis a workbook-level command — applied to a worksheet it still delegates to the workbook's SaveAs, and a PDF SaveAs always exports every visible sheet. The per-sheet loop therefore wrote N whole-workbook copies, andpublic_visual_audit.rsconcatenated them withpdfunite: every multi-sheet GT page count and text-length baseline was inflated by the sheet count (a 10-sheet workbook exported 230 GT pages for a real 23).Key changes
hideOtherVisibleSheets: walksevery sheetof the workbook, matches by name (object-specifier equality is unreliable), hides only currently-visible sheets, returns their names. Hidden/very-hidden sheets are never touched; the current sheet stays visible, so the at-least-one-visible-sheet rule can't trip.restoreSheetVisibility: restores exactly the recorded sheets before the next iteration's visibility check.tell applicationblock (they sit outside the main tell).public_visual_audit.rs(unchanged).Verification
Ran the fixed exporter through real Excel on the 10-sheet
tests/fixtures/xlsx/office2pdf_repository_workbook.xlsx:osacompileclean; Excel quit cleanlyKnown trade-off: structure-protected workbooks now fail loudly at the first hide instead of silently producing duplicated GT — preferable for a ground-truth exporter.
No Rust code touched; the default
cargo testsuite is unaffected (harness-only change consumed by the#[ignore]d visual audit on macOS).Related: #616
🤖 Generated with Claude Code