用VB 连接 EXCEL做一个报表的实例,要源代码,最好连工程一起。可以追加分
要求要用VB做一个报表,我连EXCEL做一个实例报表,谁能给我一份啊。谢谢大家帮助咯。收到后可以追加分哦。邮箱silen@live.cn谢谢哦...
要求要用VB做一个报表,我连EXCEL做一个实例报表,谁能给我一份啊。谢谢大家帮助咯。收到后可以追加分哦。
邮箱silen@live.cn
谢谢哦 展开
邮箱silen@live.cn
谢谢哦 展开
1个回答
展开全部
需要引用microsoft excel object library ..
这样就可以把数据输出到excel中
Public Sub saveToExcel12()
Dim xl As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim I As Integer, J As Integer
Set xl = CreateObject("excel.application")
If xl Is Nothing Then
MsgBox "请确认系统是否正确安装了Microsoft Excel?", vbQuestion
Exit Sub
End If
xl.Visible = True
Set xlBook = xl.Workbooks.Add
Set xlsheet = xlBook.ActiveSheet
xlsheet.Name = "结果数据"
For J = 0 To msgrid1.Rows - 1
For I = 0 To 2
msgrid1.Row = J
msgrid1.col = I
xlsheet.Cells(J + 1, I + 1) = msgrid1.Text
Next I
Next J
End Sub
这样就可以把数据输出到excel中
Public Sub saveToExcel12()
Dim xl As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Dim I As Integer, J As Integer
Set xl = CreateObject("excel.application")
If xl Is Nothing Then
MsgBox "请确认系统是否正确安装了Microsoft Excel?", vbQuestion
Exit Sub
End If
xl.Visible = True
Set xlBook = xl.Workbooks.Add
Set xlsheet = xlBook.ActiveSheet
xlsheet.Name = "结果数据"
For J = 0 To msgrid1.Rows - 1
For I = 0 To 2
msgrid1.Row = J
msgrid1.col = I
xlsheet.Cells(J + 1, I + 1) = msgrid1.Text
Next I
Next J
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询