Changed date format after saving to pdf

Hi,
the date format is changed in result pdf file.
For example:
xls: 2011-01-10 , pdf : 10.01.2011

I’m attaching xls file for testing.

Thanks in advance for help

Hi,

I have tested your file with latest Aspose.Cells for Java fix v2.5.0.3, it works fine. Here is my sample code:
//Instantiate a new workbook
Workbook book = new Workbook();

//Open an existing file
book.open(“d:\files\daty.xls”);

book.save(new FileOutputStream(“D:\files\daty.pdf”),FileFormatType.PDF);

I have also attached my output file here.

Thank you.

Hi,
thank you for reply.
I’ve checked your file and I can see dates in format dd/mm/yyyy while in the xls there is yyyy-mm-dd.
Maybe it depends on some Adobe Reader settings ?

Hi,

I think you must have specified a different locale when you converting this xls to pdf. The date format of the cell (such as “H3”) depends on locale. When you change your computer’s locale to the same one that you used to convert xls to pdf, you will see the date shown in excel for “H3” is same with the content in the generated pdf file.

Hi,
How I can change the locale used while saving xls to pdf ?
I’ve tried following methods but it doesn’t work
workbook.setRegion();
workbook.setLocale();
No matter what value I set, I always get date in format "dd.mm.yyyy"

Thanks

Hi,

To change the locale, please use JVM options like “-Duser.language=en -Duser.country=US”.

Hi,

thank you for reply.

I’m attaching test xls file and two pdf files:

dat_test_asp.pdf - generated using aspose.cells

dat_test_exc.pdf - generated using excel.



I want to receive the same result when I use aspose. That is - what I see in excel I get in pdf.



Thanks.

Hi,

Well, we have tested your case with JVM option like “-Duser.language=pl” which will set locale as polan
and the generated Pdf file is same with Excel’s result except the cell C6 which uses Zulu locale. For Zulu locale, we have tested it with several JDK versions and found none of them can format May as “uMeyi” as Excel. I think maybe current JDKs cannot support Zulu local.

Thank you.

Hi,
Thank you for reply.
I’ve tried to run my example on the Unix environment and it works fine(with the -Duser.language option).
On Windows environment despite setting the language option, I’m getting the same incorrect result.
This solution is good for me because our client runs application on Unix environment.
However the Windows env case is interesting.

Hi,

Well, we have done test on Windows. We cannot find the issue. The generated pdf is just same with what is shown in MS Excel except the cell C6 that we have already given you the explanation about it. Here is the sample code and attached it the output PDF file. I am also using JVM’s -Duser.language option to pl.

Sample code:
Workbook workbook = new Workbook();
workbook.open(“d:/files/dat_test.xls”);

workbook.save(“d:/files/output_date_test.pdf”, FileFormatType.PDF);

Thank you.



Hi,
can you provide any other solutin for this problem. Setting JVM option is unacceptable because it changes language in other applications running on the same server.

Thanks in advance

Hi,

For this requirement about changing locale, please try Workbook.getWorkbookSettings().setRegion()/setLocale() again with recent version/fix. In recent versions and fixes, we have supported to change the output number format according with user’s custom locale.

Download Link:
Aspose.Cells for Java v2.5.4.13