我正在尝试使用特殊字符和超过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();
我无法找到解决方案。