My C# Excel addon is transforming a time series into another time series.
Time series is defined as a two column range with the first column being date and second column being a floating point number.
Though my C# code is returning back DateTime for date, the Excel converts it into Excel date represented by integer and the displayed value is the integer, e.g. 39000, not a date format, e.g. 14/12/2012.
Thus, the user has to press CTRL + # to turn it into dates.
Is there a way somehow return the output of a C# excel addon already Excel formatted as Date?
a) Format the cells from the code which returns the values. E.g. if you have a handle to the range object, you can do something like
range.NumberFormat="yyyy-mm-dd".b) Pre-format the cells to a date format before running the code which imports the data. This would work if the same sheet is used each time, rather than a blank or arbitrary sheet.
c) This is an ugly hack, but try returning your date values as strings, formatted as “mm/dd/yyyy”. This should force Excel to interpret the values as dates. AFAIK the machine locale settings will not affect the translation in this case.