Inserting a Row into Excel Using ADO.NET c#
By Mash B
Inserting a Row into Excel Using ADO.NET C#
This inserts it right into the Excel Worksheet as you would expect.
string connectionString = @"Provider=Microsoft.Jet.
OLEDB.4.0;Data Source=Book1.xls;Extended
Properties=""Excel 8.0;HDR=YES;""";
DbProviderFactory factory =
DbProviderFactories.GetFactory("System.Data.OleDb");
using (DbConnection connection = factory.CreateConnection())
{
connection.ConnectionString = connectionString;
using (DbCommand command = connection.CreateCommand())
{
command.CommandText = "INSERT INTO [Cities$]
(ID, City, State) VALUES(4,\"Tampa\",\"Florida\")";
connection.Open();
command.ExecuteNonQuery();
}
}
Inserting a Row into Excel Using ADO.NET c# (959 Views)