Reputation: 1429
I have an option allowing user to select thousand seperator and decimal seperator in my windows application.How can i change the worksheet-> Cell's Number format based on selected seperators.
Upvotes: 0
Views: 1617
Reputation: 3184
The only way to specify the thousands separator and decimal separator used by a workbook in SpreadsheetGear is indirectly--by passing in a particular CultureInfo object when you initially create/open the workbook via Factory.GetWorkbook(...) or Factory.GetWorkookSet(...). SpreadsheetGear uses the various options for that CultureInfo object, such as CultureInfo.NumberFormat.NumberGroupSeparator / NumberDecimalSeparator, to format cells in the workbook.
Problem is, you cannot tweak a workbook's CultureInfo object's individual properties to use different formatting options nor can you "hot swap" one overall CultureInfo object for another while a workbook is opened.
So the only way to change things like the thousands and decimal separator characters is to:
As a result, you may need to alter your application to specify a particular region instead of individual separator characters, i.e., your user provides a region which you can use to get a particular CultureInfo object via the CultureInfo.GetCultureInfo(name) method, where name might be "en-US", "en-GB", "de-DE", "hi-IN", etc. If it helps, here is one page that lists a number of predefined CultureInfo codes.
Upvotes: 2