mike509123
MIS
I wrote the following code (code below) which opens an excel spreadsheet named Book1.xls. Afterwards it writes the text 5 in cell A7 and the text "Cell G3" in cell B7. This works okey the only issue is that when I open the spreadsheet and place the curser in cell A7 the number 5 is formatted as text nstead of a number. (warning message: The number in this cell is formatted as text or proceeded by an apostrophe)
Thanks
OleDbConnection conOleDBConnection = new OleDbConnection();
OleDbCommand comOleDBCommand = new OleDbCommand();
conOleDBConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=Book1.xls;Extended Properties=\"Excel 8.0;HDR=NO;\"";
comOleDBCommand.Connection = conOleDBConnection;
conOleDBConnection.Open();
comOleDBCommand.CommandText = "UPDATE [Sheet1$A7:B7] SET F1 = 5, F2 = 'Cell G3'";
comOleDBCommand.ExecuteNonQuery();
conOleDBConnection.Close();
Thanks
OleDbConnection conOleDBConnection = new OleDbConnection();
OleDbCommand comOleDBCommand = new OleDbCommand();
conOleDBConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=Book1.xls;Extended Properties=\"Excel 8.0;HDR=NO;\"";
comOleDBCommand.Connection = conOleDBConnection;
conOleDBConnection.Open();
comOleDBCommand.CommandText = "UPDATE [Sheet1$A7:B7] SET F1 = 5, F2 = 'Cell G3'";
comOleDBCommand.ExecuteNonQuery();
conOleDBConnection.Close();