如何将Excel单元格的数据类型更改为单元格值?c#中的字符串

本文关键字:单元格 字符串 Excel 数据类型 | 更新日期: 2023-09-27 18:07:20

如何改变DataType = CellValues。c#中每个excel列的字符串

for (int index = 0; index < NoOfRecords; index++)
 {
   for (int j = 0; j < colCount; j++)
    {                            
      mWSheet1.Cells[(rowCount) + index, j + 1] =Convert.ToString(ResultsData.Rows[index][j].ToString());
    }
}

如何将Excel单元格的数据类型更改为单元格值?c#中的字符串

在每个集合前面放一个字符串格式("'"+)

for (int index = 0; index < NoOfRecords; index++)
 {
   for (int j = 0; j < colCount; j++)
    {                            
      mWSheet1.Cells[(rowCount) + index, j + 1] ="'"+Convert.ToString(ResultsData.Rows[index][j].ToString());
    }
}