ExcelNumberFormat icon indicating copy to clipboard operation
ExcelNumberFormat copied to clipboard

Date incorrectly formatted when format code starts with [$-F800]

Open GradlonGwen opened this issue 7 months ago • 3 comments

In a workbook created with Excel 365 on a French system, i have this format: "[$-F800]dddd,\ mmmm\ dd,\ yyyy".

<numFmt formatCode="[$-F800]dddd\,\ mmmm\ dd\,\ yyyy" numFmtId="164"/>

In Excel, this is displayed like this: "jeudi 25 juillet 2024".

image

Using ExcelNumberFormat API, With the culture set to "Fr-fr" and using the value 45498, the output of the formatting will be: "jeudi, juillet 25, 2024", which is not a valid French representation of a date.

It seems that usually these kind of codes "[$-HEX CODE]" refers to locale code, but in this case, I did not find any formal documentation about this particular code "[$-F800]". According to exchanges on the internet, it seems to refer to the system long date format (and therefore ignore the formatting coming after the square brackets?).

In ExcelNumberFormat.Parser.ParseSection code, I understand that this code is not interpreted. Actually, it fells in the TryParseCurrencySymbol case. Thus, only the part after the square brackets are used for the formatting, resulting in the incorrect string value mentionned above.

I am wondering if someone knows about that, and if they know how to manage such conditions?

GradlonGwen avatar Jul 25 '24 15:07 GradlonGwen