Foxtable(狐表)用户栏目专家坐堂 → 大数据量导出到EXCEL的代码,为啥导不出数据


  共有2035人关注过本帖树形打印复制链接

主题:大数据量导出到EXCEL的代码,为啥导不出数据

帅哥哟,离线,有人找我吗?
blackzhu
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:狐仙 帖子:9879 积分:57634 威望:0 精华:15 注册:2008/9/1 9:45:00
大数据量导出到EXCEL的代码,为啥导不出数据  发帖心情 Post By:2016/10/27 17:44:00 [显示全部帖子]

数据导不到,但是也没有出错. 
   Public Sub ExportToExcel(ByVal inSQL As String, ByVal inFileName As String)

        Dim oleDbComd As New OleDb.OleDbCommand()

        Dim ldbConn As New OleDb.OleDbConnection
        Dim dataReader As OleDb.OleDbDataReader

        Dim xlApp As Excel.Application
        Dim xlWorkBook As Excel.Workbook
        Dim xlWorkSheet As Excel.Worksheet
        Dim xlQueryTable As Excel.QueryTable

        On Error Resume Next

        ldbConn.ConnectionString = ldbConn.ConnectionString
        ldbConn.Open()

        xlApp = CreateObject("Excel.Application")
        xlWorkBook = Nothing
        xlWorkSheet = Nothing
        xlWorkBook = xlApp.Workbooks.Add()
        xlWorkSheet = xlApp.Worksheets("sheet1")
        xlApp.Visible = False
        Dim myconn As String = "数据源字符串"
        xlWorkSheet.QueryTables.Add(myconn, xlWorkSheet.Range("A1"), inSQL)

        With xlQueryTable
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = Excel.XlCellInsertionMode.xlInsertDeleteCells
            .SavePassword = True
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .PreserveColumnInfo = True
        End With

        xlQueryTable.FieldNames = True
        xlQueryTable.Refresh()
        xlWorkBook.SaveAs(inFileName)

        xlApp.Quit()
        xlApp = Nothing
        xlWorkBook = Nothing
        xlWorkSheet = Nothing
        dataReader.Close()
        GC.Collect()
    End Sub

 回到顶部
帅哥哟,离线,有人找我吗?
blackzhu
  2楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:狐仙 帖子:9879 积分:57634 威望:0 精华:15 注册:2008/9/1 9:45:00
  发帖心情 Post By:2016/10/28 9:31:00 [显示全部帖子]

 狐表在不分页的情况下,最多可以加载多少条数据?

 回到顶部