I need to open an existing Excel file and fill it with a DataTable. How can I do that?
I am working in ASP.NET
I have already tried to create an excel with this solution (http://stackoverflow.com/questions/1746701/export-datatable-to-excel-file) and then I tried to open it with an OLEDB connection like this, but it didn't work.. it said that the table was not in a correct format.. and then it said that ir couldn't find the ISAM file.. I don't know what to do..
System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\reports\report.xls;Extended Properties=""Excel 8.0;HDR=No;IMEX=1""");
conn.Open();
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = @"SELECT * INTO [Excel 8.0;Database=C:\reports\reportBase.xls].[SheetBase1] FROM Sheet1]";
cmd.ExecuteNonQuery();
conn.Close();
Please help me!! I'm desperate!!
Thank you!!