Fix phone number format: escaped dashes misidentified as grouping chars; decimal cast in special format classes#1710
Merged
Conversation
…s grouping chars, fix decimal cast in SSN/Zip/Phone format classes Co-authored-by: tonyqus <772561+tonyqus@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix NPOI phone number formatting issue
Fix phone number format: escaped dashes misidentified as grouping chars; decimal cast in special format classes
Mar 1, 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.
DataFormatterincorrectly formats phone numbers like###\-###\-####as1-234-56-7-890instead of123-456-7890, andSSNFormat/ZipPlusFourFormat/PhoneFormatthrowInvalidCastExceptionwhenFormatRawCellContentspasses adecimalvalue.Changes
DataFormatter.cs— alternate grouping detection: RunalternateGrouping.Match()against the original format string (beforecleanFormatForNumberstrips backslashes). After stripping,###\-###\-####becomes###-###-####and the regex incorrectly captures-as an alternate grouping separator. Matching on the raw string avoids this because the backslash breaks the[#0]{3}contiguity requirement.Format.cs— decimal cast fix: Replace(double)objwithConvert.ToDouble(obj, CultureInfo.InvariantCulture)inSSNFormat,ZipPlusFourFormat, andPhoneFormat, consistent withDecimalFormat. The direct cast throws whenobjis adecimal, which is whatFormatRawCellContentsproduces.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.