DateTime style number doesn't work properly

I wrote the following example :

Excel excel = new Excel();
Worksheet sheet = excel.Worksheets[0];

sheet.Cells[0, 0].PutValue(DateTime.Now);
sheet.Cells[0, 0].Style.Number = 14; // 14 Date m/d/yy

It’s alright, in Excel Cell value type is Date

but if i do like this :

sheet.Cells[0, 1].PutValue(DateTime.Now);
sheet.Cells[0, 1].Style.Number = 18; // 18 Time h:mm AM/PM
sheet.Cells[0, 1].Style.Number = 19; // 19 Time h:mm:ss AM/PM
sheet.Cells[0, 1].Style.Number = 20; // 20 Time h:mm
sheet.Cells[0, 1].Style.Number = 21; // 21 Time h:mm:ss
sheet.Cells[0, 1].Style.Number = 22; // 22 Time m/d/yy h:mm

in Excel Cell i have a good formatting time value, but value type is Custom, it is not Time



I test your code and all work fine.

Which version are you using? The latest version is v2.8.0.1. Please download it at

and have a try.

Yes, i have used the latest version 2.8.0.1 but I have got the same result. Maybe it depends on my local settings ( i have russian ), isnt’t ?

I don’t think it’s a local setting issue. Please verify if the version of Aspose.Excel.dll is v2.8.0.1 in your GAC.

And if possible, please zip your whole test project and send it to me by email. I will check it ASAP.

After checking your project and file, I find it’s really a locale setting issue. However, you needn’t care about it. Though the number format is custom, it’s still datetime type. If you use Cell.Type property in Aspose.Excel, you can find the cell type is DateTime.

OK, thanks, it’s enough for me, but my customer maybe won’t very happy. Smile

I think it doesn’t matter. It shows the correct format and correct type. Big Smile

I mean thought the shown cell type is “Custom”, it’s still DateTime type “h:mm”.