Remove [Platform("Win")] from TestVBAMacroReader; fix AutoSizeColumn on Linux#1715
Merged
Conversation
Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix AutoSizeColumn to resize all columns correctly
Fix AutoSizeColumn only resizing one column on existing workbooks
Mar 5, 2026
…lbacks Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot
AI
changed the title
Fix AutoSizeColumn only resizing one column on existing workbooks
Fix AutoSizeColumn persisting only first column; make font measurement work cross-platform
Mar 6, 2026
…atform Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot
AI
changed the title
Fix AutoSizeColumn persisting only first column; make font measurement work cross-platform
Remove [Platform("Win")] from font-related tests — make them work on Linux
Mar 6, 2026
… font fallback Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot
AI
changed the title
Remove [Platform("Win")] from font-related tests — make them work on Linux
Make all tests run on Linux by fixing font handling and VBA macro line endings
Mar 6, 2026
Copilot
AI
changed the title
Make all tests run on Linux by fixing font handling and VBA macro line endings
Remove [Platform("Win")] from TestVBAMacroReader; fix AutoSizeColumn on Linux
Mar 6, 2026
This was referenced Apr 6, 2026
This was referenced Apr 6, 2026
This was referenced Apr 27, 2026
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.
TestVBAMacroReaderwas gated to Windows-only andAutoSizeColumn/AutoSizeRowfailed on Linux due to font rendering errors and three correctness bugs. This PR makes both work cross-platform.AutoSizeColumn correctness bugs (XSSFSheet)
Three independent bugs prevented correct column sizing in existing workbooks:
CT_Cols.BreakUpCtColoff-by-one:lastColumnis 0-based,ctCol.min/ctCol.maxare 1-based — fix: uselastColumn + 1AutoSizeColumnTracker.SetMaxColumnWidthsself-reference:withSkipMergedCellswas compared againstwithUseMergedCellsinstead of itself, so unmerged width was never tracked independentlyXSSFSheet.AutoSizeColumnwrong column updated:SetColBestFit()inserted a new<col>element instead of updating the one just resized — replaced withGetColumn(column)?.IsBestFit = trueAutoSizeColumn on Linux (
SheetUtil.cs)All
TextMeasurercalls now catchFontException | InvalidFontFileException(thrown on Linux when font tables are missing) with graceful fallbacks:charCount × (fontHeightPx × 0.5)— preserves relative differences across fonts/rotationssize × dpi / 727(≈ pixel width of'0'in Calibri 11pt @ 96 DPI)VBAMacroReader cross-platform (
TestVBAMacroReader.cs)SimpleMacro.vbatest files have Unix\nendings butVBAMacroReaderreturns CRLF from Office binaries —Containscomparisons always failed on Linux. Fixed by normalizing before comparison:Also changed
FileAccess.ReadWrite→FileAccess.Read(file is only read), and removed the[Platform("Win")]class attribute.EscherGraphics font fallback
GetFontFamilyOrFallbacknow iterates system fonts and skips any that throwInvalidFontFileException(e.g. the APT-installedNotoColorEmoji.ttfwhich lacks the requiredlocatable), rather than crashing onSystemFonts.Families.First().Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.