Append / Add Output To Excel SpreadsheetFeb 24, 2011
I am creating a report and outputting the results to an excel file. Here is how it is suppose to work. I have a table called EMPID that has a list of employee id's. I loop through this table and for each EMPID, I run several queries. I would like to append the data that is returned to the spreadsheet so that the results for all EMPID's would be added to the spreadsheet. Right now, the way I have coded it, for each EMPID it overwrites the fields in the spreadsheet instead of adding/appending them to it.
Here is some code:
If EmpidDS.Tables("EMPID_Table").Rows.Count <> 0 Then
For Each dr As System.Data.DataRow In EmpidDS.Tables("EMPID_Table").Rows
'Set the variable EMPID to the current row EMPID
EMPID = dr.Item("EMPID")
'Check that table is not empty