There appear to be a number of suggestions to do this, non of which appear to work.
Effectively, I'm wanting to change a text value in an Excel sheet to a number (this is a cell that has been set as a number stored as text, and has a green diamond next to it).
This webpage details how to resolve the issue in Excel, through the UI, and I've recorded this as a macro below (but that's VBA)...
Including setting the value to itself:
Range allCellsRng;
string lowerRightCell = "AZ500";
allCellsRng = wSheet.get_Range("A1", lowerRightCell).Cells;
foreach (Range cell in allCellsRng)
{
if (cell.Value2.ToString().Length > 0)
{
cell.Value2 = cell.Value2;
}
}
This is a recorded VB Macro, that shows what will resolve the issue, but I'm having problems representing this in C#:
ActiveCell.FormulaR1C1 = "0"
Range("A1").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select