DateFormat dd.mm.yyyy for Cell

Hi,


How can i set value of the cell as a date with format dd.mm.yyyy?

Best regards,
Kamil.

Hi,


Thanks for your query.

Please see the following sample code for your reference:
e.g
Sample code:

Workbook workbook = new Workbook();
Cell cell = workbook.Worksheets[0].Cells[“A1”];
cell.PutValue(DateTime.Now);

Style style = cell.GetStyle();
// Custom Date format.
style.Custom = “dd.mm.yyyy”;

//Apply the style to cell.
cell.SetStyle(style);

//Extend the column’s width to display the formatted datetime value.
workbook.Worksheets[0].AutoFitColumn(0);
workbook.Save(“e:\test2\out1testcustomformat1.xlsx”);

Hope, this helps a bit.

Thank you.

Hi,


Thanks for sample. It generally works. It has a correct view. But there is strange issue. Please look in attachments.
I wanna set cell format like in “Etalon” file, but with “style.Custom = “dd.mm.yyyy”” I’m geting cell format like in AssignmentExecutionDeadlineControl. It looks similar but not same.
I understand that russians date formats may be not popular for your customer, but it will be nice to see support of such formats in your product as standard (not Custom) in future.

Best regards,
Kamil.

Hi,


Thanks for the template files and screenshots with details.

Could you try the following line if it works for your needs:
e.g
Sample code:

style.Number = 14;

Hopefully it will work for your requirements. We think it will work if the default Date separator is ‘.’ for Russian.

Please note:
1) Well, when you specify built-in numbers formatting for a cell’s data and save the Excel file, now when you open the file into MS Excel, it would be automatically converted to the numeric, DateTime, etc. value as per the locale/regional settings of the machine.

Also, see the Table on what built-in numbers formats we support for your reference:

2) When you specify numbers formatting using Custom attribute, the formatted value is independent and won’t be changed by the locale or region.

Thank you.

Hi,


Your solution is exactly what I need! Thanks a lot for help.

Best regaerds,
Kamil.

Hi,


Good to know that your issue is sorted out now. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.