dim ex as object dim exbook as object dim exsheet as object dim a(255) as string set ex=createobject("excel.application") ex.visible=true set exbook=nothing set exsheet=nothing set exbook=ex.workbooks.add set exsheet=exbook.worksheets("sheet1") ex.range("a1")=text1.text & vbcrlf ex.Range("A1") = Left(ex.Range("A1"), Len(ex.Range("A1")) - 2)
打印你可以利用excel中的打印方法
Dim cn as Adodb.Connection Dim rs as Adodb.Recordset Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet数据库连接,查询Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Add Set xlSheet = xlBook.Worksheets(1)'//将数据填充至EXCEL中 Dim iCurrentRow,iCurrentCol,i as integer iCurrentRow =1:iCurrentCol =1 For i = 0 to rs.Fields.Count - 1 xlsheet.cells(iCurrentRow,iCurrentCol) = rs.Fields(i).Name iCurrentCol = iCurrentCol + 1 NextiCurrentRow = iCurrentRow+1:iCurrentCol =1 Do While Not rs.Eof For i = 0 to rs.Fields.Count - 1 xlsheet.cells(iCurrentRow,iCurrentCol) = rs.Fields(i).Value iCurrentCol = iCurrentCol +1 Next iCurrentRow = iCurrentRow+1:iCurrentCol =1 rs.Movenext Loop'//打印 xlSheet.PrintOut Set xlSheet = Nothing Set xlBook = Nothing '如要自动关闭EXCEL,请加入 xlApp.Quit Set xlApp = Nothing
dim exbook as object
dim exsheet as object
dim a(255) as string
set ex=createobject("excel.application")
ex.visible=true
set exbook=nothing
set exsheet=nothing
set exbook=ex.workbooks.add
set exsheet=exbook.worksheets("sheet1")
ex.range("a1")=text1.text & vbcrlf
ex.Range("A1") = Left(ex.Range("A1"), Len(ex.Range("A1")) - 2)
Dim rs as Adodb.Recordset
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet数据库连接,查询Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)'//将数据填充至EXCEL中
Dim iCurrentRow,iCurrentCol,i as integer
iCurrentRow =1:iCurrentCol =1
For i = 0 to rs.Fields.Count - 1
xlsheet.cells(iCurrentRow,iCurrentCol) = rs.Fields(i).Name
iCurrentCol = iCurrentCol + 1
NextiCurrentRow = iCurrentRow+1:iCurrentCol =1
Do While Not rs.Eof
For i = 0 to rs.Fields.Count - 1
xlsheet.cells(iCurrentRow,iCurrentCol) = rs.Fields(i).Value
iCurrentCol = iCurrentCol +1
Next
iCurrentRow = iCurrentRow+1:iCurrentCol =1
rs.Movenext
Loop'//打印
xlSheet.PrintOut
Set xlSheet = Nothing
Set xlBook = Nothing
'如要自动关闭EXCEL,请加入 xlApp.Quit
Set xlApp = Nothing