Hi, I'm making a program to save data to excel file. I've accomplished saving the DataGridView I'm using to a Excel File. My question is "Can you save a excel file without overwriting the previous information on the excel file?" In other words can I just update the excel file?
here's my code...
Thanks in advance!
here's my code...
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim i As Integer
Dim o As Integer
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
For i = 0 To dgvRecentOrders.RowCount - 2
For o = 0 To dgvRecentOrders.ColumnCount - 1
xlWorkSheet.Cells(i + 1, o + 1) = dgvRecentOrders(o, i).Value.ToString()
Next
Next
xlWorkSheet.SaveAs("C:\testexcel.xlsx")
xlWorkBook.Close()
xlApp.Quit()
Thanks in advance!