I'm trying to use Infragistics to create an Excel file from another Excel file with the following code:
Dim wb As New Infragistics.Excel.Workbookwb.Load( "c:\exceltemplate.xls")
Dim ws As Infragistics.Excel.Worksheet = wb.Worksheets("sheet1")
Dim rowIndex As Integer = 1
For Each drow As DataRow In dt.Rows
Dim row As Infragistics.Excel.WorksheetRow = ws.Rows.Item(rowIndex)
rowIndex = rowIndex + 1
For columnIndex As Integer = 0 To drow.ItemArray.Length - 1
row.Cells.Item(columnIndex).Value = drow.ItemArray(columnIndex)
Next
The file c:\exceltemplate.xls has 1 sheet called "sheet1" with some column headers in it. It errors on the line "Dim ws As Infragistics.Excel.Worksheet = wb.Worksheets("sheet1")" because wb has no worksheets in it so the load appears to be doing nothing. Am I doing something wrong?
Thanks