使用 Vb.net 导出到 Excel + Windows应用程序
简单代码:
Private Sub ExportGridToExcel()
Dim Excel As Object = CreateObject("Excel.Application")
If Excel Is Nothing Then
MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical)
Return
End If
'Make Excel visible
Excel.Visible = True
'Initialize Excel Sheet
With Excel
.SheetsInNewWorkbook = 1
.Workbooks.Add()
.Worksheets(1).Select()
'How to bind entire grid into excel without looping...
End With
Excel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
Excel = Nothing
MsgBox("Export to Excel Complete", MsgBoxStyle.Information)
End Sub
如何将整个网格绑定到Excel而不循环..
Simple code :
Private Sub ExportGridToExcel()
Dim Excel As Object = CreateObject("Excel.Application")
If Excel Is Nothing Then
MsgBox("It appears that Excel is not installed on this machine. This operation requires MS Excel to be installed on this machine.", MsgBoxStyle.Critical)
Return
End If
'Make Excel visible
Excel.Visible = True
'Initialize Excel Sheet
With Excel
.SheetsInNewWorkbook = 1
.Workbooks.Add()
.Worksheets(1).Select()
'How to bind entire grid into excel without looping...
End With
Excel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(Excel)
Excel = Nothing
MsgBox("Export to Excel Complete", MsgBoxStyle.Information)
End Sub
How to bind entire grid in to excel without looping..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设网格你指的是datagridview?我认为您无法将数据绑定到 Excel。我前段时间写了这个,将 datagridview 导出到 excel:
I assume by the grid you mean a datagridview? I don't think you will be able to bind your data to excel. I wrote this some time ago to export a datagridview to excel: