public static void XLSWriter(string filename, string desiredcell, double number)
{
try
{
string path = @"c:\Documents and Settings\rdockter\My Documents\" + file + "";
string connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties=\"Excel 8.0;HDR=NO;READONLY=FALSE\"";
OleDbConnection conn = new OleDbConnection(connectionstring);
OleDbCommand command = new OleDbCommand();
conn.Open();
command.Connection = conn;
string Sql = "UPDATE [Sheet1$" + desiredcell + ":" + desiredcell + "] SET F1='" + number + "';";
command.CommandText = Sql;
command.ExecuteNonQuery();
conn.Close();
}
catch (OleDbException ex)
{
Console.WriteLine("Error: {0}", ex);
}
}
Try using this little method.