I have a Wpf application in which I want to insert data row to excel file. At the time when datarow is added to the datatable, I want that datarow to get saved in Excel file.
Datarow should be saved in excel file before this C# statement:
table.Rows.Add(datarow);
This process will be repeated each time when Datarow is added to datatable.It should not replace the previous data present in the Excel file, rather it should append datarow to excel file each time.
try the below code and make sure add
Microsoft.Office.Interop.Excel
dll reference from references.If you want you can optimize the code further but the below one works for your basic understanding