|
'-作者;Grant
'-时间;2008-1-14'-Email;20991943@qq,cin
'-QQ;20991943
'-网站;www.accessbbs.cn
'-博客;http://www.accessbbs.cn/bbs/blog/?uid/3
'-简介;应网友所求导出DataGrid到Excel
Dim oExcel As Object
Dim oBook As Object
Dim I, J As Integer
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add()
oExcel.Visible = True
For I = 1 To DataGrid1.Columns.Count
oBook.Worksheets(1).Cells(1, I) = DataGrid1.Columns(I - 1).Caption
For J = 0 To DataGrid1.VisibleRows - 1
oBook.Worksheets(1).Cells(J + 2, I) = DataGrid1.Columns(I - 1).CellText(DataGrid1.RowBookmark(J))
Next J
Next I
Set oBook = Nothing
Set oExcel = Nothing |
|