I have two datasets in which i have brands in one table and products in other table. I have to export this information to excel like printing the first row in the excel and then all the related products below that line and so on
Brandname BrandID
Nike 1
Nike Shoes 1 240$
Nike Shirts 23 78$
yamaha 1
Bike 13 2440$
motor 233 4578$
i have ried like this but its not alligning properly
Dim i, j As Integer
Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWorkSheet As Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
For i = 0 To ds.Tables(0).Rows.Count - 1
For j = 0 To ds.Tables(0).Columns.Count - 1
xlWorkSheet.Cells(i + 1, j + 1) = _
ds.Tables(0).Rows(i).Item(j)
Next
For k = 0 To ds2.Tables(0).Rows.Count - 1
For l = 0 To ds2.Tables(0).Columns.Count - 1
xlWorkSheet.Cells(i + k + 2, i + l + 2) = _
ds2.Tables(0).Rows(k).Item(l)
Next
Next
Next
xlWorkSheet.SaveAs("D:\vbexcel.xlsx")
xlWorkBook.Close()
xlApp.Quit()
it has come up like this
This kind of gives you similar layout