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

Free Support Forum - aspose.com

Date Formats

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am evaluating Aspose.CeIls and having some issues setting date formats as follows:

I am trying to display the date as ‘mmm-yy’, for example Dec-14.

This works fine when using a DateTime:


Style style = ws.Cells["A1"].GetStyle();

style.Number = 17;


However I need to use strings as follows:


Style style_2 = ws.Cells["A2"].GetStyle();

style_2.Number = 17;


The above method produces a date in Excel as "10/11/2014" even though the properties of the cell correctly show the format of ‘mmm-yy’. If I double click the cell then the value appears in the correct format.

Any idea how to make this work with date strings?


Well, actually the line of code i.e., ws.Cells[“A2”].PutValue(“10/11/2014”); is inserting string into the cell instead of DateTime value, so you are not getting expected results in the output Excel file. Please make sure that you paste DateTime data type value into the cell, the easiest way to do it is you should let Aspose.Cells do convert it into DateTime automatically, you may simply put “true” for isConverted parameter in the PutValue() overloaded method to convert the string into proper data type (DateTime value in your case).

Please change the line of code,

ws.Cells[“A2”].PutValue(“10/11/2014”, true);

it would work fine.

Thank you.