Set CultureInfo on workbook level

Hello team,

I’m currently configuring the culture at the workbook level, but the data doesn’t seem to be saving with the new culture. I have to individually set the format for each cell to ensure it adopts the new culture. Is there a way to automatically apply the new culture to the data when I set it at the workbook level, and then have the ability to save and load the data with the updated culture settings?

@Jayshiv,

I think you may try to use Workbook.Settings.Region attribute to set the region/locale (as per your desired culture) before saving to Excel file or PDF.
e.g.,

workbook.Settings.Region = CountryCode.Russia;
workbook.Settings.LanguageCode = CountryCode.Russia;

For loading Excel file with your desired locale/region, you may try to specify region while loading the XLSX file.

LoadOptions options = new LoadOptions();
options.Region = CountryCode.Denmark;
Workbook workbook = new Workbook("e:\\test2\\Book1.xlsx", options); 

In case, you still find any issue, please provide the resource files (input file (if any), current output file by Aspose.Cells and your expected output file) and sample code snippet to evaluate your issue.

Hi Team,

Please find attached zip for more info. I have explain there what exactly we need.

following is my code.
var excelPath = @“D:\myexcel.xlsx”;
var culture = new CultureInfo(“de-IT”);
Workbook wblob = new Workbook(excelPath);
wblob.Settings.CultureInfo = culture;
wblob.Settings.Region = CountryCode.Italy;
wblob.Settings.LanguageCode = CountryCode.Italy;

wblob.Save(@“D:\output_excel.xlsx”);
usa_format.zip (13.4 KB)

@Coder365,

Thanks for the sample file, details and code segment.

I evaluated your files and code segment. Yes, this is expected behavior/result, same as MS Excel. Please note, when you render/save to Excel (e.g., XLSX) file format and then you open the resultant XLSX file into MS Excel manually, data/values into the cells will be shown based on the current locale/region (set) for your OS. But if you need to save to PDF file, then the data/values in the output PDF pages will be rendered based on the region/language set in your code. For example, if you could save to PDF by adding a line to your code segment, the output PDF file has data as per your desired culture/locale/region:

wblob.Save(@"D:\output_pdf.pdf");