-2

I am having some Cell values printed as Taxt (String) and i want them to be printed as Number, as this values are used in a Sum Formula.

The values came from an operation that i do with a library (OSISoft AF SDK) and are printed in my Excel as Strings.

ExcelRange cell = excelSheet.Cells[startRow, startCol + i + y];
cell.Value =  valueAsString;

Just in case someone is using AF SDK as me getting data from PI Systems my code is actually something like this...

//point is a PIPoint.

cell.Value = point.RecordedValue(startDate.LocalTime.AddHours(i), OSIsoft.AF.Data.AFRetrievalMode.AtOrBefore);

1 Answers1

0

Just parsing the value to double (or int) will be okey.

cell.Value = Double.Parse(cell.Value.ToString());

You can also set a Format to the number, but it is not necessary:

cell.Style.Numberformat.Format = "0.00";

All formats available:

https://stackoverflow.com/a/40214134/6574873