Dim ds As DataSet Dim i, j As Integer ds = objGPBLL.getGridView() 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.ApplicationClass 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 Next xlWorkSheet.SaveAs("D:\vbexcel.xls") xlWorkBook.Close() xlApp.Quit() MsgBox("You can find the file D:\vbexcel.xls")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)