I need to programmatically insert a row into an Excel Spreadsheet multiple times. I need to actually insert a new row and not insert data, that is, I need to actually shift all other rows down by one.
I am currently using OleDB to insert the data itself like so:
//Note I have missed some code out for simplicities sake, this all works fine however
OleDbConnection oledbConn = null;
OleDbCommand cmd = null;
OleDbConnection = new OleDbConnection(connString);
OleDbConnection.Open();
string connString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0; \"", TargetFile);
sting InsertCommand = string.Format("INSERT INTO [{0}${1}:{1}] Values({2})", WorksheetName, Coord, valuestring);
cmd = new OleDbCommand(InsertCommand, oledbConn);
cmd.ExecuteNonQuery();
//close etc
I want to be able to insert a row in a similar fashion. Is this possible?