导出超过255个字符和特殊字符以在C#中优于单元格

时间:2013-10-24 07:27:44

标签: c# asp.net excel .net-4.0 export-to-excel

我正在尝试使用特殊字符和超过255个字符将某些数据导出到excel,而不是将其插入到Excel中。

我正在使用Office Interop 4.0框架。

OleDbDataAdapter dbadapter = null;
OleDbConnection excelConnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + this.ProcessedFileName + "; Extended Properties=Excel 12.0" + ";Persist Security Info=False");
foreach (DataRow dr in dataTable.Rows)
{
      string sqlStquery = @"Insert into [Consumer$] ([Consumer Number],[Name],[Address1],[Address2],[City]) Values ('" + dr["Consumer Number"] + "','" + dr["Name"] + "','" + dr["Address1"] + "','" + dr["Address2"] + "','" + dr["City"] + "')";

      dbadapter = new OleDbDataAdapter(sqlStquery, excelConnection);
      dbadapter.SelectCommand.ExecuteNonQuery();
}
dbadapter.Dispose();
excelConnection.Close();
excelConnection.Dispose();

我无法找到解决方案。

0 个答案:

没有答案