'把datagridview中的数据导出到excel PublicSub dgExportToExcel()Sub dgExportToExcel(ByVal DGV As DataGridView) Dim wapp AsNew Microsoft.Office.Interop.Excel.Application Dim wsheet As Microsoft.Office.Interop.Excel.Worksheet Dim wbook As Microsoft.Office.Interop.Excel.Workbook 'Dim wapp As New Excel.Application 'Dim wsheet As Excel.Worksheet 'Dim wbook As Excel.Workbook OnErrorResumeNext wapp.Visible =True '打已有的excel模板文件 wbook = wapp.Workbooks.Open(System.IO.Directory.GetCurrentDirectory().ToString() &"HTXX.xlt") '方式一: 'wsheet = wbook.ActiveSheet '方式二: wsheet = wbook.Worksheets("Sheet1") Dim iX AsInteger Dim iY AsInteger
这两天在研究怎样将DataGridView和listview 中的数据导出到Excel中这两个控件基本方法是一样,只需要将 DGV(iY, iX) 改成listview.item即可 把datagridview中的数据导出到excel Public Sub dgExportToExcel()Sub dgExportToExcel(ByVal DGV As DataGridView)