Fix rich text rendering in PDF export and stop mutating source workbook#2371
Closed
swmal wants to merge 3 commits into
Closed
Fix rich text rendering in PDF export and stop mutating source workbook#2371swmal wants to merge 3 commits into
swmal wants to merge 3 commits into
Conversation
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.
Summary
Fixes a rich text rendering bug in PDF export and removes a serious side effect where the export mutated the source workbook.
Changes
PdfTextMapnow readscell.RichTextvia the public property (which lazy-loads from XML) instead of the internal_rtcfield. Cells whose_rtchappened to be null previously had their rich text formatting flattened to a single run of plain text.GetTextFragmentsno longer creates anExcelRichTextCollectionfor plain-text cells. That constructor had a hidden side effect — it setCellFlags.RichTextand overwrotecell.Value, silently corrupting user data on export.PdfCatalog(settings, worksheet, stream)andExcelPdf.CreatePdf(stream)overloads for in-memory export.ExcelColor.ToColor(): New public helper that resolves theme, tint, indexed, and RGB to aSystem.Drawing.Color.How to verify
Export a workbook containing both rich-text and plain-text cells, then export it again from the same
ExcelPackageinstance. Both exports should succeed and render rich text correctly without altering the source workbook.