Date format

I would like to format a date cell this way:

18.01.2016 16:27:37.358

Which is the corresponding value for TFlxFormat.Format?

I tried "dd/mm/YYYY hh:nn:ss.000", but that did not work

I am not sure on the specifics, but whenever you have a doubt like this, you can find it out with APIMate. Just format the cell as you want it in Excel, then save the file and open it in APIMate. It will tell you the format you need. 


In this case, I did the above procedure and got this code:
  //Set the cell values
  fmt := xls.GetCellVisibleFormatDef(3, 1);
  fmt.Format := 'dd/mm/yyyy\ hh:mm:ss.000';
  xls.SetCellFormat(3, 1, xls.AddFormat(fmt));
  xls.SetCellValue(3, 1, TFlxDateTime.ToOADate(EncodeDateTime(1994, 7, 19, 10, 54, 16, 138), xls.OptionsDates1904));


For what it is worth, the format Excel itself shows is:
dd/mm/yyyy hh:mm:ss.000

which is normally similar to what you would write in Excel, but there are localization issues. So it is best to get the format from APIMate

I don't know APIMate. Is it part of RAD Studio?
But I have found a solution:

fmt.Format := 'DD.MM.YYYY hh:mm:ss.000';

Markus

APIMate is part of FlexCel. Just search for it in the Windows start menu.


Whenever you have a doubt on "how to" do something, the simplest way is to do it in Excel, then save the file and open it with APIMate. APIMate will tell you the code to recreate that file with FlexCel code.


Very good tool:

  fmt := xls.GetCellVisibleFormatDef(2, 2);
  fmt.Format := 'DD.MM.YYYY hh:mm:ss.000';
  xls.SetCellFormat(2, 2, xls.AddFormat(fmt));
  xls.SetCellValue(2, 2, TFlxDateTime.ToOADate(EncodeDateTime(2016, 1, 19, 9, 51, 35, 879), xls.OptionsDates1904));