Free Support Forum - aspose.com

Custom cell style format

I’m doing something like this:

cell.Style.Custom = “#.##0,00 “kW””;

But when I view the created Excel file, the format of a cell reads

#,##000 "kW"

I.e. the comma “,” was removed and the dot “.” was converted to a comma “,”.

My environment is German (german .NET Framework, german Excel). In Germany, the dot “.” is the 1000-separator and the comma “,” is the decimal separator whereas in the English language it is just the other way.

Am I running into culture problems here or is this related to something different?

Thanks
Uwe

Yes. This must be a culture issue. Could you please try:

cell.Style.Custom = “#,##0.00 “kW””;

Cool! Now it works as expected, i.e. it converts it again to

#.##0,00 "kW"

which is what I want in the resulting Excel document.

(Before your tip, I also tried setting the current threads culture back from German to the InvariantCulture, but without success).

Questions:

- Can I expect it to work now on all platforms (my development Server is German, but the release server is English)
- Will you add culture-awareness to upcoming releases so this works always as expected?
- Could you explain this behaviour at all? Maybe if I understand what’s going on, I know how to handle similar scenarios.

Thanks
Uwe

If you set custom string "#.##0,00 “kW” " in MS Excel, it will convert it to “#,##0.00 “kW””. Aspose.Excel doesn’t care about the culture. It save the format string as your settings.


1. It will work on all platforms.
2. Culture-awareness is too complex and time-consuming. We will check this issue but don’t have any plan for this. Please set your custom string same as format with InvariantCulture.