Fix unspecified XLSX paper size default - #144
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Paper size propagation can inherit a stale firstExplicitPaperSize if a sheet’s PaperSize is normalized after the value is captured, potentially causing inconsistent paper sizes across sheets in the same workbook.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR aligns XLSX-to-PDF page sizing with Microsoft 365 output by defaulting worksheets that omit paperSize to A4, while keeping explicit paperSize="1" as US Letter, and adds regression coverage for both behaviors.
Changes:
- Default missing XLSX
paperSizeto A4 during sheet read/normalization. - Add tests validating A4 default when
paperSizeis omitted and Letter when explicitly set. - Update inline documentation to reflect the new default behavior for unspecified
paperSize.
File summaries
| File | Description |
|---|---|
| tests/MiniPdf.Tests/ExcelToPdfConverterTests.cs | Adds regression tests for default A4 and explicit Letter paper size handling. |
| src/MiniPdf/ExcelReader.cs | Adjusts paper size propagation/defaulting logic and updates related comments. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } | ||
| if (sheet.PaperSize == 0) | ||
| { | ||
| sheet.PaperSize = firstExplicitPaperSize ?? | ||
| (sheet.Rows.Count >= 1000 && sheet.ColumnWidths.Count == 0 && sheet.DefaultColumnWidth <= 0f ? 9 : 1); | ||
| sheet.PaperSize = firstExplicitPaperSize ?? 9; | ||
| } |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughExcel conversion now defaults unspecified worksheet paper sizes to A4. Explicit Letter settings remain supported. Tests verify the resulting A4 and Letter page dimensions. ChangesExcel paper-size defaults
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
paperSizeto A4, matching the Microsoft 365 benchmark outputpaperSize="1"as US LetterValidation
dotnet test tests/MiniPdf.Tests: 188 passedclassic84_travel_destination_cards: MiniPdf and reference PNGs both1241 x 17540.9582to0.9963Summary by CodeRabbit