ExcelNumberFormat icon indicating copy to clipboard operation
ExcelNumberFormat copied to clipboard

Conversion from .NET format strings to Excel format strings?

Open madelson opened this issue 5 years ago • 1 comments

Hi @andersnm,

This is probably out of scope for the library, but given that you are likely knowledgeable on the subject I thought I'd ask.

I have an app which allows format strings to be configured by an admin for how different numeric values are displayed in the UI. We use .NET format strings for this purpose. However, I want to support exports and be as faithful as possible in converting the .NET format string to an Excel one.

The two formatting "languages" are similar but not the same. I'm considering using your library to "TryParse" the .NET format string and see if it happens to be compatible with Excel as a first step. Does the library do enough validation for this to work?

Also, I'm generally curious whether you've seen this use-case or problem before and if there are any robust solutions you've encountered.

Thanks in advance, Mike

madelson avatar Feb 20 '20 21:02 madelson

Hi @madelson,

I know there are many similarities between the .NET and Excel formats such that many strings work with either, but I'm also pretty sure there are sufficient differences that it wouldn't be a robust solution. ExcelNumberFormat would likely allow and interpret any .NET-format-specific tokens as literals. Alas I don't have any details or examples off the top of my head.

Lately there's been a couple indirect requests to convert certain number formats from .NET to Excel in the ExcelDataReader project, although for this I am considering a more specialized converter rather than a general one. I'm not aware of any existing solutions, but haven't looked much. https://github.com/ExcelDataReader/ExcelDataReader/issues/461#issuecomment-582248735

andersnm avatar Feb 20 '20 22:02 andersnm