Hi,
I'm having a problem getting the excel component to do some simple date math. If I apply the following formula:
wb.Worksheets[
"X"].Rows[0].Cells[0].CellFormat.FormatString = "m/d/yy";wb.Worksheets[
"X"].Rows[0].Cells[0].ApplyFormula("=1/1/2010 + 10");
I'm expecting what Excel would give me: "1/11/2010", instead, I get the following answer:
10.0004975124378
Any tips?
A better approach would be to use the formula "=DATE(2010,1,1) + 10". Testing this formula in Excel I get the expected result.
The formula that you are applying is a numerical formula and returns a numerical answer rather than a date answer. If I test that formula in Excel without setting a format string then I get the same answer, 10.0005. If I do set the format string so that the cell is a date then I get 1/10/1900.