国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
VB DataGrid 的導(dǎo)出或打印
導(dǎo)出到d:\text2.xls中
Private Sub Command2_Click()
Dim i     As Integer
  Dim j     As Integer
  Dim xlApp     As New Excel.Application
  Dim xlBook     As New Excel.Workbook
  Dim xlSheet     As New Excel.Worksheet
  Set xlApp = CreateObject("Excel.Application")
  xlApp.Visible = True
  Set xlBook = xlApp.Workbooks.Add
  On Error Resume Next
  Set xlBook = xlApp.Workbooks.Open("d:\text2.xls")
  Set xlSheet = xlBook.Worksheets(1)
  For j = 0 To DataGrid1.Columns.Count - 1
  xlSheet.Cells(1, j + 1) = DataGrid1.Columns.Item(j).Caption
  Next j
  xlSheet.Cells(6, 1) = "i"
  adodc1.Recordset.MoveFirst
  For i = 0 To adodc1.Recordset.recordcount - 1
  'For j = 0 To DataGrid1.Columns.Count - 1 '這一行跟下一行效果一樣
  For j = 0 To adodc1.Recordset.fields.Count - 1
  xlSheet.Cells(i + 1, j + 1) = adodc1.Recordset(j)
  Next j
  adodc1.Recordset.movenext
  Next i
End Sub
提問(wèn)人的追問(wèn)   2009-08-15 14:30
用戶(hù)類(lèi)型未定義
回答人的補(bǔ)充   2009-08-15 14:49

不好意思,忘記說(shuō)了 。

在工程——引用里,添加Microsoft Excel 11.0 Object Library即可

回答人的補(bǔ)充   2009-08-15 14:49
提問(wèn)人的追問(wèn)   2009-08-15 14:52

恩~~除了標(biāo)題外~~沒(méi)有任何內(nèi)容~

回答人的補(bǔ)充   2009-08-15 14:58
Dim i     As Integer
  Dim j     As Integer
  Dim xlApp     As New Excel.Application
  Dim xlBook     As New Excel.Workbook
  Dim xlSheet     As New Excel.Worksheet
  Set xlApp = CreateObject("Excel.Application")
  xlApp.Visible = True
  Set xlBook = xlApp.Workbooks.Add
  On Error Resume Next
  Set xlBook = xlApp.Workbooks.Open("d:\text2.xls")
  Set xlSheet = xlBook.Worksheets(1)
  For j = 0 To DataGrid1.Columns.Count - 1
  xlSheet.Cells(1, j + 1) = DataGrid1.Columns.Item(j).Caption
  Next j
  xlSheet.Cells(6, 1) = "i"
  Adodc1.Recordset.MoveFirst
  For i = 0 To Adodc1.Recordset.RecordCount - 1
  DataGrid1.Row = i
  For j = 0 To DataGrid1.Columns.Count - 1
  DataGrid1.Col = j
  'MsgBox   DataGrid1.Text
   
  If IsNull(DataGrid1.Text) = False Then
  xlSheet.Cells(i + 2, j + 1) = DataGrid1.Text
  End If
  Next j
  Next i

提問(wèn)人的追問(wèn)   2009-08-15 14:59
問(wèn)下~要是不導(dǎo)出可以直接打印那個(gè)DataGrid1里面的內(nèi)容嗎?
回答人的補(bǔ)充   2009-08-15 15:02

可以的!

 

Private Sub Command3_Click()
On Error GoTo ErrMsg
fnt = 15
X = 1000
Y = 1000
Dim i As Long, J As Long, K As Long
Dim PrintString As String
Y = 4400
Printer.CurrentX = 1000
Printer.CurrentY = 4000
Printer.FontSize = 13
Printer.Print "學(xué)號(hào)/姓名 /課程/成績(jī)/班級(jí)"
For i = 0 To DataGrid1.Row
If K = DataGrid1.VisibleRows Then
DataGrid1.Scroll 0, DataGrid1.VisibleRows
K = 0
End If
For J = 0 To DataGrid1.Columns.Count - 1
PrintString = PrintString & _
DataGrid1.Columns(J).CellText(DataGrid1.RowBookmark(K)) & "/"
Next
Printer.CurrentX = 1000
Printer.CurrentY = Y
Printer.FontSize = 10
Printer.Print PrintString
PrintString = ""
K = K + 1
Y = Y + 300
DoEvents
   If i = DataGrid1.Row Then    '無(wú)此條件則打印機(jī)與計(jì)算機(jī)不斷開(kāi),不能進(jìn)行新的打印任務(wù)
Printer.EndDoc
End If
Next
ErrMsg:
  If Err.Number <> 0 Then
     MsgBox CStr(Err.Number) + Err.Description, vbOKOnly + vbCritical, "錯(cuò)誤提示"
     Exit Sub
  End If
End Sub
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
VB.Net出口Excel原則
VB將excel數(shù)據(jù)導(dǎo)入數(shù)據(jù)庫(kù)以及將數(shù)據(jù)庫(kù)數(shù)據(jù)導(dǎo)入excel源代碼 .: NOVOTS KMS
VB 讀取Excel表的內(nèi)容 |VB 網(wǎng)|VB 視頻教程|VB編程入門(mén)網(wǎng)
VB導(dǎo)出EXCEL實(shí)例
利用VB設(shè)計(jì)打印復(fù)雜報(bào)表
VB打開(kāi)EXCEL的方法
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服