I have an Microsoft.Office.Interop.Excel.Range which I fill with Data and set a new NumberFormat, like that:
wkbActive = (Excel.Workbook)Globals.ThisAddIn.Application.ActiveWorkbook;
wksActive = (Excel.Worksheet)wkbActive.ActiveSheet;
Excel.Range rngExample = wksActive.get_Range("A1");
rngExample.Value = "08.06.2015";
rngExample.NumberFormat = "ddd, d. M";
example.NumberFormat = "ddd, d. M";
The problem is that the new NumberFormat isnĀ“t apply until I click into the cell. Is there an "update" Method or sth for the Range?!
This is because you're setting the cell value to a
string
and this is not evaluated as a date until you click into the cell and press 'Enter'.Excel stores dates as
double
which represents a time since 1900. You should set theValue2
property to aDateTime
per this example: