I have encountered an issue with conditional formatting when my PC's region and language settings are set to something other than English (specifically, French or Italian). When I create my spreadsheet and add a conditional format, in the <conditionalFormatting> section of sheet.xml, the <x:formula> field is storing the value with the CurrentCulture decimal separator (i.e. ',') instead of InvariantCulture (i.e. '.'). When the spreadsheet is opened by Excel I get an error saying Excel found unreadable content. If I click Yes to recover, I get the following message from the recovery report:
Removed Feature: Conditional formatting from /xl/worksheets/sheet.xml part
I have tried changing the CurrentCulture to "en" just before adding a conditional format (and restoring after) but then the <x:formula> field is stored as a string (although with the correct decimal separator) which gives undesired results in Excel.
Please Advise,
James Martin
Comments: Here are two examples of how I add conditional formatting: ``` ws.Range(fr, fc, lr, lc).AddConditionalFormat().WhenEqualOrLessThan(SlmConstants.InvalidVal) .Font.SetFontColor(XLColor.LightGray); ws.Range(fr, fc, lr, lc).AddConditionalFormat().WhenBetween(0, cf.ValOne) .Fill.SetBackgroundColor(XLColor.LightGray); ``` When my PC locale is en-US I get a '.' decimal separator, as expected, in the resulting xml. However, if my locale is set to fr-FR, for example, the decimal separator in the xml file is ',' (comma) which Excel considers 'unreadable content' and removes all conditional formatting. Regards, James Martin
Removed Feature: Conditional formatting from /xl/worksheets/sheet.xml part
I have tried changing the CurrentCulture to "en" just before adding a conditional format (and restoring after) but then the <x:formula> field is stored as a string (although with the correct decimal separator) which gives undesired results in Excel.
Please Advise,
James Martin
Comments: Here are two examples of how I add conditional formatting: ``` ws.Range(fr, fc, lr, lc).AddConditionalFormat().WhenEqualOrLessThan(SlmConstants.InvalidVal) .Font.SetFontColor(XLColor.LightGray); ws.Range(fr, fc, lr, lc).AddConditionalFormat().WhenBetween(0, cf.ValOne) .Fill.SetBackgroundColor(XLColor.LightGray); ``` When my PC locale is en-US I get a '.' decimal separator, as expected, in the resulting xml. However, if my locale is set to fr-FR, for example, the decimal separator in the xml file is ',' (comma) which Excel considers 'unreadable content' and removes all conditional formatting. Regards, James Martin