0

We have VBA for exporting data from FlexGrid to Excel. This is done with assigning cell formats to the columns. We are migrating the project to VB.NET where we are following the same process by assigning the date format to the cells as below:

objWorkSheet.Cells(irow, icol).EntireColumn.NumberFormat = "dd/mm/yyyy"

I am able to see the correct date format in Excel after exporting. For example: "30/10/2010". But the same is not the case in a test environment where this date appears as "10/30/2010". I have tested on another developer machine that also shows "10/30/2010" though it displays correctly on my machine, whose date format is "dd/MM/yyyy".

What it is happening I don't understand?

pnuts
  • 58,317
  • 11
  • 87
  • 139
Hemant Kumar
  • 4,593
  • 9
  • 56
  • 95
  • Need to see a code sample. My guess is that the date value is being converted to a string (based on the current regional settings) before it is passed to Excel. – JDB Nov 02 '12 at 12:53
  • I think that .NET is implicitly calling `ToString()` on the date value before it is being passed to Excel. The result of `ToString()` would depend on the computer's regional settings. A number format only works on numbers. If you are passing "10/30/2010" as a string to Excel, it may simply be treating it as text. But without a code sample (of where you are actually setting the value, not just the format) it is impossible to say for sure. – JDB Nov 02 '12 at 17:32

0 Answers0