Skip to content

fix(harness): export each Excel GT sheet as its own PDF - #708

Merged
developer0hye merged 1 commit into
mainfrom
fix/excel-gt-sheet-export
Jul 30, 2026
Merged

fix(harness): export each Excel GT sheet as its own PDF#708
developer0hye merged 1 commit into
mainfrom
fix/excel-gt-sheet-export

Conversation

@developer0hye

Copy link
Copy Markdown
Owner

What changed

scripts/macos/export_excel_pdfs.applescript now hides every other visible sheet (chart sheets included) around each per-sheet save as, then restores exactly the sheets it hid, so each <id>-sheet-NNNN.pdf contains exactly one worksheet.

Why

Excel's AppleScript save as is 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, and public_visual_audit.rs concatenated them with pdfunite: 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: walks every sheet of 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.
  • Both handlers wrap Excel terminology in their own tell application block (they sit outside the main tell).
  • Convention decided per the issue's open question: all visible sheets, one PDF per sheet, matching what the converter renders and the existing pdfunite combine step in public_visual_audit.rs (unchanged).

Verification

Ran the fixed exporter through real Excel on the 10-sheet tests/fixtures/xlsx/office2pdf_repository_workbook.xlsx:

  • 10 per-sheet PDFs, page counts 1, 5, 3, 1, 1, 6, 1, 2, 1, 2 — sum exactly 23 (before: every PDF was the whole 23-page workbook)
  • each PDF samples to its own sheet's text; all file sizes distinct
  • osacompile clean; Excel quit cleanly

Known 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 test suite is unaffected (harness-only change consumed by the #[ignore]d visual audit on macOS).

Related: #616

🤖 Generated with Claude Code

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>
@developer0hye
developer0hye merged commit 8fd53b6 into main Jul 30, 2026
16 of 17 checks passed
@developer0hye
developer0hye deleted the fix/excel-gt-sheet-export branch July 30, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant