We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Excel Workbook get Language

We are using the Aspose library to generate a Html preview off a Excel file. With the generation off this file, all the Dates are formatted in English formatting due to the English version of Windows. And not based on the language off the Excel file.

So my question is, if it’s possible to retrieve the language that was used when saving the Excel file.
So I can use it to force the right dateformat using: lWorkbookSettings.setRegion(CountryCode.NETHERLANDS);

We already checked lWorkbookSettings.getLanguage, .getLanguageId and getRegion but they always return 0
And getLocale returns the language off the server and not the file…

I’m using Aspose.Cell version:
Release-Date: 2014-07-03
Implementation-Version: 8.1.1.0


Hi Jeroen,

Thanks for your posting and using Aspose.Cells.

Please provide us some Excel file which has some language other than English. Please provide us a screenshot how it looks in Microsoft Excel and also provide PDFs of it generated by Microsoft Excel and Aspose.Cells for our reference.

It will help us look into your issue more closely and precisely and we will be able to help you asap.

Our understanding is that Excel file does not have any language of its own. Excel shows the file according to the Regional and Language Options - Time and Date Formats - settings which are applied via Control Panel inside the Windows.

I added some attachments.
The first attachment is a simple test excel file with some dates in it (created on a pc with Dutch settings).
The second is the generated pdf on a server with Dutch language settings.
The third is the generated pdf on a server with English language settings.
And the fourth is a screenshot off Excel on my own computer with Dutch language settings.

Our understanding is that Excel file does not have any language of its own. Excel shows the file according to the Regional and Language Options - Time and Date Formats - settings which are applied via Control Panel inside the Windows.

Thus this mean that Excel doesn’t save which language was used when saving the file?

Hi Jeroen,

Thanks for your posting and using Aspose.Cells.

There are no language of Excel file on its own. Microsoft Excel shows the date formats according to the local date and time format settings. This is the reason, your Excel file looks different on Dutch computer and on US computer.

In the same way, Aspose.Cells generates the PDF according to the current Locale.

Please see the following code. It saves the PDF in Dutch(Belgium) locale first, then it saves the PDF in English(United States).

I have attached the output PDFs generated by the code for your reference.

Java


String filePath = “F:\Shak-Data-RW\Downloads\Dates.xlsx”;


//Create workbook object

Workbook workbook = new Workbook(filePath);


//Print the default Locale

Locale loc = Locale.getDefault();


System.out.println(loc.getCountry());

System.out.println(loc.getLanguage());


//Save PDF in Dutch(Belgium)

Locale.setDefault(new Locale(“nl”, “BE”));

workbook.save(filePath + “.NL.pdf”);


//Save PDF in English(United States)

Locale.setDefault(new Locale(“en”, “US”));

workbook.save(filePath + “.US.pdf”);

Similarly instead of changing the Locale of entire application, you can also set the Locale of just Workbook using Workbook.getSettings().setLocale() method. Please see the following code. It works same as above code.

Java
String filePath = "F:\\Shak-Data-RW\\Downloads\\Dates.xlsx";

//Create workbook object
Workbook workbook = new Workbook(filePath);

//Print the default Locale
Locale loc = Locale.getDefault();

System.out.println(loc.getCountry());
System.out.println(loc.getLanguage());

//Save PDF in Dutch(Belgium)
workbook.getSettings().setLocale(new Locale("nl", "BE"));
workbook.save(filePath + ".NL1.pdf");

//Save PDF in English(United States)
workbook.getSettings().setLocale(new Locale("en", "US"));
workbook.save(filePath + ".US1.pdf");