在C#中使用C#Causing System .__ ComObject写入Excel

时间:2013-08-22 19:02:57

标签: c# .net excel

我正在尝试将数据从List<string>写入Excel文件中的单元格。

下面可以看到代码,因为我尝试将列表“rawDTCs”中的字符串写入excel表。

for (int x = 0; x < rawDTCs.Count; x++)
{
     excelWorkSheet.Cells[myRow, 25] += rawDTCs[x];
}

我没有收到列表中的字符串,而是收到以下内容。

enter image description here

我是否需要投射数组列表以避免出现此错误?如何才能使列表中的字符串打印到单元格?

1 个答案:

答案 0 :(得分:1)

这样做。

((Microsoft.Office.Interop.Excel.Range)excelWorkSheet.Cells[myRow, 25]).Value2 = 
rawDTCs[x];
相关问题