I'm hoping someone here has even a remote clue how to do the following, because I've spent three days off and on looking at this and can't find a definitive answer. I know the Software forum is the appropriate place for this question, but it seems to not see even half the traffic that Off Topic does. In any case, does anyone know if it's possible to add a column to an Excel spreadsheet using JUST ADO.NET (absolutely no Office automation)? The following C# code throws an "Invalid Operation" error:
OleDbConnection conExcel = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\myexcelfile.xls;Extended Properties=\"Excel 8.0;HDR=YES;\"");
conExcel.Open();
OleDbCommand cmdExcel = new OleDbCommand("ALTER TABLE [Sheet1$] ADD columnname VARCHAR(20)", conExcel);
cmdExcel.ExecuteNonQuery();
OleDbConnection conExcel = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\myexcelfile.xls;Extended Properties=\"Excel 8.0;HDR=YES;\"");
conExcel.Open();
OleDbCommand cmdExcel = new OleDbCommand("ALTER TABLE [Sheet1$] ADD columnname VARCHAR(20)", conExcel);
cmdExcel.ExecuteNonQuery();
