I'd like to get a list of strings from an Excel range where the data could be mixed types (strings, doubles, etc.). I tried using this:
List<string> rangeToList(Excel.Range inputRng)
{
object[,] cellValues = (object[,])inputRng.Value2;
List<string> lst = cellValues.Cast<string>().ToList();
return lst;
}
But the line with Cast<string>
returns this error:
Unable to cast object of type 'System.Double' to type 'System.String'
How can I convert this array of objects into my desired list?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…