vb,vsfilegrid控件自带的方法导出数据到excel(求源码案例)?
vb6.0吧
全部回复
仅看楼主
level 1
ouyeniu_88 楼主
[乖]
2013年11月27日 03点11分 1
level 11
二楼
2014年02月17日 05点02分 2
level 2
我会,很简单
Dim i As Integer, r As Integer, c As Integer
Dim newxls As Excel.Application
Dim newbook As Excel.Workbook
Dim newsheet As Excel.Worksheet
Set newxls = CreateObject("Excel.Application")
Set newbook = newxls.Workbooks.add
Set newsheet = newbook.Worksheets(1)
If Adodc1.Recordset.RecordCount > 0 Then
For i = 0 To DataGrid1.Columns.Count - 1
newsheet.Cells(1, i + 1) = DataGrid1.Columns(i).Caption
Next i
Adodc1.Recordset.MoveFirst
Do Until Adodc1.Recordset.EOF
r = Adodc1.Recordset.AbsolutePosition
For c = 0 To DataGrid1.Columns.Count - 1
DataGrid1.Col = c
newsheet.Cells(r + 1, c + 1) = DataGrid1.Columns(c)
Next c
Adodc1.Recordset.MoveNext
Loop
newxls.Visible = True
End If
2014年10月15日 12点10分 3

2014年10月20日 01点10分
1