MMM-YY format in Aspose Cells with Excel Type Date

Hello, I am struggling to write a new Date() in Excel in the format MMM-YY. i tried style.setNumber(17). It successfully writes in desired format but the Excel Type is set to Custom not Date. How to do the same but set Excel Type to Date?

Please provide sample of the code if someone solves this issue in Aspose Cells for java.

@k4b1n,

I am able to reproduce the issue as you mentioned by using the following sample code. I found an issue with setNumber attribute for “mmm-yy” Date format which is set as custom format. When using Style.setNumber(17), it successfully writes in desired format “mmm-yy” but the Excel type is set to Custom and not Date.
e.g.
Sample code:

// Instantiating a Workbook object
Workbook workbook = new Workbook();

// Obtaining the reference of first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);

// Adding the current system date to "A1" cell
worksheet.getCells().get("A1").putValue(DateTime.getNow());

// Getting the Style of the A1 Cell
Style style = worksheet.getCells().get("A1").getStyle();

// Setting the display format to number 17 to show date as "mmm-yy"
style.setNumber(17);

// Applying the style to the A1 cell
worksheet.getCells().get("A1").setStyle(style);

// Saving the Excel file
workbook.save("f:\\files\\book1.out.xlsx");

We need to investigate your issue in details. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-45474

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@k4b1n
Please find the corresponding format in Excel,

  1. Select the desired format in Date type,
  2. Click Custom to view the format string
    Then set the corresponding format to the file through Aspose.Cell.Style.Custom.