Hi Vikram,
Thanks for your posting and using Aspose.Cells.
You will have to select a per-defined Locale. For example, if you want to support dd/MM/yyyy date format, you will have to select UK Locale or similar.
Also, you should search on internet if you can customize your Locale settings and specify your own custom date format.
I have also logged your comment in our database against this issue and we will let you know if such a thing is possible or not.
Hi Vikram,
Thanks for your using Aspose.Cells.
We are afraid we cannot find the way to modify the default formatting
rules of one specific Locale with Java’s formatting APIs. You have to
choose the Locale which can format datetime as what you expect.
Hi Shakeel Faiz,
Hi Vikram,
Thanks for your using Aspose.Cells.
You should change the Built-In date format to Custom format. Please see the following code, it changes the built-in date formats to custom formats.
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> Workbook wb = <span style=“font-size:10.0pt;font-family:“Courier New”;color:#7F0055”>new<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> Workbook(<span style=“font-size:10.0pt;font-family:“Courier New”;color:#2A00FF”>“example.xlsx”<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”>);<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> <span style=“font-size:10.0pt;font-family:“Courier New”;color:#7F0055”>for<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”>(<span style=“font-size:10.0pt;font-family:“Courier New”;color:#7F0055”>int<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> i=wb.getCountOfStylesInPool()-1; i>-1; i–)<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> {<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> Style s = wb.getStyleInPool(i);<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> <span style=“font-size:10.0pt;font-family:“Courier New”;color:#7F0055”>if<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”>(s != <span style=“font-size:10.0pt;font-family:“Courier New”;color:#7F0055”>null<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> && s.getNumber() == 14)<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> {<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> s.setCustom(<span style=“font-size:10.0pt;font-family:“Courier New”;color:#2A00FF”>“dd/MM/yy”<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”>);<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> }<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> }<span style=“font-size:10.0pt;font-family:“Courier New””>
<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”> wb.save(<span style=“font-size:10.0pt;font-family:“Courier New”;color:#2A00FF”>“res.pdf”<span style=“font-size:10.0pt;font-family:“Courier New”;color:black”>);Please understand the difference between Built-in formats and Custom formats.
Built-in
formats are represented by numbers and their display depends on the
User Date and Language settings. While custom formats are represented by
format string and they are independent of User Date and Language.
To explain the difference between them in detail, I have attached the MS-Word document with screenshots. Please download it and read it.
I have also attached the source excel file used in these screenshots for your reference.
Hi Shakeel Faiz,
Hi Vikram,