I tried to insert rows in excel with OLEDB and the problem is :
ex :
public void Insert (string text, Excel.Worksheet ws, string column){
OleDbCommand cmd1 = new OleDbCommand("INSERT INTO ["+ws.Name+"$] " + "([" + column + "]) VALUES(' " + text + " ')", _oleConn); cmd1.ExecuteNonQuery(); }
It could be that the Worksheet is keeping the XML of those columns behind the scenes. Your current code places the row at the end of the worksheet. The code would have to be modified to delete the empty row(s) before the row you want to put in, and then add. An example would be this:
public void Insert (string text, Excel.Worksheet ws, string column){
OleDbCommand cmd0 = new OleDbCommand("DELETE FROM ["+ws.Name+"$] where /*column1*/ = '' AND /*column2*/ = '' /*...*/ AND /*columnN*/ = ''", _oleConn);
cmd0.ExecuteNonQuery();
OleDbCommand cmd1 = new OleDbCommand("INSERT INTO ["+ws.Name+"$] " +
"([" + column + "]) VALUES(' " + text + " ')", _oleConn);
cmd1.ExecuteNonQuery();
}