I'm trying to export some data to excel with special chars and more than 255 chars, its not getting inserted into the excel.
I'm working on 4.0 Framework with Office Interop.
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();
I am not able to find the solution.