你看一下关于sql的书不就完了嘛?
解决方案 »
- datagridview即时刷新问题(网络)
- c# 定义属性时,在属性类型前加“?”是什么意思?
- 在.net的控制台应用程序下如何获取键盘按下的值,请大虾帮忙!!!
- 关于正则表达式
- hashtable是不是只能在它调用Add()的方法内使用它?
- treeview如何才能显示为全部展开啊
- FTP文件上传后,服务器如何返回处理结果给客户端
- 用C#编写的Windows应用程序是不是一定要在安装.net Framework才能运行
- OpenText Document Management是否有C#的开发接口
- 如何通过软件调用微信端口给好友发信息?
- 在webApplication中弹不出MessageBox()?
- TO:bluesx(独上西楼)还是关于自己创建异常类的问题(你写的那个程序)
Public m_xlBook As Excel.Workbook
Public m_xlSheet As Excel.WorksheetPublic m_strFileName As StringPrivate Sub Class_Initialize()
m_strFileName = "Books1.xls"
Set m_xlApp = New Excel.Application
Set m_xlBook = m_xlApp.Workbooks.Add
Set m_xlSheet = m_xlBook.Sheets(1)
m_xlApp.Visible = False
End SubPrivate Sub Class_Terminate()
m_xlBook.Close False
m_xlApp.Quit
Set m_xlApp = Nothing
Set m_xlBook = Nothing
Set m_xlSheet = Nothing
End SubPublic Function OpenSaveAsFileName(strFileNameDefault As String) As Variant
On Error Resume Next
Dim strFileName As Variant
strFileName = m_xlApp.GetSaveAsFilename(strFileNameDefault, "Microsoft Excel 工作薄(*.xls),*.xls")
If strFileName <> False Then
Me.m_strFileName = CStr(strFileName)
End If
OpenSaveAsFileName = strFileName
If Err Then
Err.Clear
End If
End FunctionPublic Sub SaveCurrExportedExcel()
On Error Resume Next
m_xlBook.SaveAs m_strFileName
If Err Then
Err.Clear
End If
End SubPublic Function AdodcExport(ByRef ctrADO As Adodc, ByVal nSheetStartRow As Long, ByVal nSheetStartCol As Long) As Long
'''------------------------------------------------------
''' For Test Only:
Dim nRow As Long
Dim nCol As Long
On Error Resume Next
ctrADO.Recordset.MoveFirst
If Err Then
Err.Clear
AdodcExport = 0
Exit Function
End If
nRow = nSheetStartRow
nCol = 0
Do While (ctrADO.Recordset.EOF = False And ctrADO.Recordset.BOF = False)
nRow = nRow + 1
For nCol = 1 To ctrADO.Recordset.Fields.Count Step 1
m_xlSheet.Cells(nRow, nCol + nSheetStartCol).Value = Trim(ctrADO.Recordset.Fields(nCol - 1).Value)
Next nCol
ctrADO.Recordset.MoveNext
If Err Then
Err.Clear
End If
Loop
AdodcExport = nRow
End FunctionPublic Function ResExport(ByRef rsADO As ADODB.Recordset, ByVal nSheetStartRow As Long, ByVal nSheetStartCol As Long) As Long
'''------------------------------------------------------
''' For Test Only:
Dim nRow As Long
Dim nCol As Long
On Error Resume Next
If rsADO.EOF Or rsADO.BOF Then
Exit Function
End If
rsADO.MoveFirst
If Err Then
Err.Clear
ResExport = 0
Exit Function
End If
nRow = nSheetStartRow
nCol = 0
Do While (rsADO.EOF = False And rsADO.BOF = False)
nRow = nRow + 1
For nCol = 1 To rsADO.Fields.Count Step 1
m_xlSheet.Cells(nRow, nCol + nSheetStartCol).Value = Trim(rsADO.Fields(nCol - 1).Value)
Next nCol
rsADO.MoveNext
If Err Then
Err.Clear
End If
Loop
ResExport = nRow
End Function