我想将带有列标题的mysql表数据导出到Excel工作表。我正在使用vb.net。但我无法在excel表中获得表列标题。我只得到mysql表数据。
my code
-------
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.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.xlsx")
xlWorkBook.Close()
xlApp.Quit()
答案 0 :(得分:1)
我不了解Vb.net,但我有类似的问题,不得不使用语法:
声明中的IGNORE 1 LINES。
http://dev.mysql.com/doc/refman/5.1/en/load-data.html(这是用于导入,但此处描述了IGNORE 1 LINES语法...)