Improve Excel preflight and report evidence#1979
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e338b05e87
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1979 +/- ##
==========================================
- Coverage 73.43% 73.42% -0.01%
==========================================
Files 2541 2548 +7
Lines 288094 288829 +735
Branches 61942 62114 +172
==========================================
+ Hits 211563 212083 +520
- Misses 48375 48528 +153
- Partials 28156 28218 +62 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8626839ed7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d55c43734
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c188fca75a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c70eb2262
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab44e38886
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 10ae2714ed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return false; | ||
| } | ||
|
|
||
| if (!OfficeImageReader.TryIdentify(bytes, null, out OfficeImageInfo imageInfo)) { |
There was a problem hiding this comment.
Validate images with the PDF writer
When a worksheet image is declared as PNG/JPEG but only has a recognizable header or otherwise uses a PNG payload the PDF writer rejects, this preflight returns supported because it stops at OfficeImageReader.TryIdentify. The export path later calls TryValidatePdfImageBytes and skips those images with a warning, so CanExportPdfReport can still approve a report that drops visuals; use the same PDF byte validator here.
Useful? React with 👍 / 👎.
| foreach (var section in EnumerateHeaderFooterSections(headerFooter)) { | ||
| if (!TryGetUnsupportedHeaderFooterFormattingReason(section.Text, out string reason)) { |
There was a problem hiding this comment.
Detect mixed header/footer styles
When one header/footer zone uses a line-level style that the PDF exporter can only apply if it is shared across all zones, for example left &BTotal and center Page &P, each section passes this independent scan and CanExportPdfReport remains true. The exporter later compares the resolved styles across left/center/right and first/even/default zones, warns about mixed formatting, and simplifies the header/footer, so preflight misses a PDF formatting loss.
Useful? React with 👍 / 👎.
| var pdfExportFormulas = formulas.Formulas | ||
| .Where(formula => defaultPdfExportSheetNames.Contains(formula.SheetName)) | ||
| .ToArray(); |
There was a problem hiding this comment.
Scope PDF formula checks to exported cells
When a visible worksheet has an unsafe formula cache only outside the default PDF export range, such as a dirty formula outside a single print area or in a hidden row/column, this sheet-name-only filter still adds PDF-missing/dirty formula caches and blocks ExportPdfReport. The default exporter reads the configured print area and respects hidden rows/columns before collecting cell values, so those formulas are never rendered and preflight rejects a PDF the default path can produce without touching them.
Useful? React with 👍 / 👎.
| if (!TrySkipHeaderFooterFontToken(text, ref i)) { | ||
| reason = "malformed font formatting"; |
There was a problem hiding this comment.
Validate header/footer font tokens
When a header/footer starts with a quoted font token whose family the PDF font mapper cannot apply, for example &"UnmappedFont"Report, this scan skips the token and treats the section as PDF-safe because no visible text has been seen yet. The exporter later calls TryApplyHeaderFooterFontToken, emits a WorksheetHeaderFooterFormatting warning when mapping fails, and simplifies the header/footer, so CanExportPdfReport can approve a report with known formatting loss.
Useful? React with 👍 / 👎.
| ExcelSheet.HeaderFooterSnapshot headerFooter = excelSheet.GetHeaderFooter(); | ||
| AddUnsupportedHeaderFooterImages(headerFooter, sheetName, ref pdfUnsupportedImageCount, pdfUnsupportedImageDetails); | ||
| AddUnsupportedHeaderFooterFormatting(headerFooter, sheetName, ref pdfUnsupportedHeaderFooterFormattingCount, pdfUnsupportedHeaderFooterFormattingDetails); | ||
| AddUnsupportedPrintArea(excelSheet, sheetName, ref pdfUnsupportedPrintAreaCount, pdfUnsupportedPrintAreaDetails); |
There was a problem hiding this comment.
Add print-title columns to PDF preflight
When a visible worksheet defines print-title columns, this print-layout preflight can still pass because it only checks multi-area print areas and never records GetPrintTitles().HasColumns. The default PDF export path only has UseWorksheetPrintTitleRows handling and prepends repeated rows, so workbooks that expect left columns repeated on each printed page are approved even though those print-title columns are ignored in the generated PDF.
Useful? React with 👍 / 👎.
Summary
Validation
FeatureReport_Preflight|FullyQualifiedNameCompatibility_Corpus_PreserveOnlyMetadata_RoundTripsAndBlocksRiskyWorkflows|FullyQualifiedNameCompatibility_Corpus_MacroEmbeddedObjectsAndControls_RoundTripAndBlockRiskyWorkflows|FullyQualifiedNameReportWorkflow_TemplateFormulaChartPivot_PreflightsAndExportsPdf" --no-build --logger "console;verbosity=minimal"