I am trying to localize the excel cell value using .Net spreadsheetgear dll, When i try to generate the excel i am suing the portugese number format as "[=0]0;###.###,00" which should display the value as 2.265,65 , but this is not happening and it is displaying as 2,265.65( "." is not getting replaced with "," for portugese), Please help me is there any limitations in the excel or do we need to apply anyother number format
Thanks
Sudha
You can control some localization aspects of a workbook such as currency, dates as well as the number group and decimal separators, by passing a particular CultureInfo
type when creating or opening a workbook file in SpreadsheetGear. The Factory.GetWorkbook(...) and Factory.GetWorkbookSet(...) methods are overloaded to accept this CultureInfo
object. If you do not specify a CultureInfo
object, SpreadsheetGear defaults to "en-US".
My guess is that your workbook set is currently using "en-US" because you did not specify a Portugese CultureInfo
type. Below is an example that should demonstrate how to get your above NumberFormat
to appear as expected with SpreadsheetGear:
// Create a new workbook specifying "pt-BR" CultureInfo
IWorkbook workbook = Factory.GetWorkbook(CultureInfo.GetCultureInfo("pt-BR"));
IWorksheet worksheet = workbook.ActiveWorksheet;
IRange cells = worksheet.Cells;
cells["A1"].NumberFormat = "[=0]0;###.###,00";
cells["A1"].Value = 2265.65;
Console.WriteLine(cells["A1"].Text);
// Output: 2.265,65