Foxtable(狐表)用户栏目专家坐堂 → 导出数据时提示超出65536行(已改为xlsx)


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

主题:导出数据时提示超出65536行(已改为xlsx)

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


加好友 发短信
等级:一尾狐 帖子:430 积分:4655 威望:0 精华:0 注册:2015/3/21 14:25:00
导出数据时提示超出65536行(已改为xlsx)  发帖心情 Post By:2023/4/29 10:24:00 [只看该作者]

Dim Filter As String
With RibbonTabs("运单管理").Groups("运单管理").Items("上游客户")
    If .text > "" Then
        Filter = "上游客户 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("运单管理").Groups("运单管理").Items("品牌")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "品牌 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("运单管理").Groups("运单管理").Items("上游动态")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "上游动态 like '%" & .text & "%'"
    End If
End With

With RibbonTabs("运单管理").Groups("运单管理").Items("运输单号")
    If .text > "" Then
        If Filter > "" Then
            Filter = Filter & " And "
        End If
        Filter = Filter & "运输单号 like '%" & .text & "%'"
    End If
End With


Dim cmd As New SQLCommand
cmd.C 
Dim nms() As String = {"部门", "上游客户", "品牌", "商品车", "运输单号", "VIN码"}
If Filter > "" Then
    cmd.CommandText = "Sel ect 部门,上游客户,品牌,商品车,运输单号,VIN码 F rom {运单管理} Where '" & Filter & "' "
Else
    cmd.CommandText = "Sel ect 部门, 上游客户, 品牌, 商品车, 运输单号, VIN码  F rom {运单管理} "
End If

Dim dt As DataTable = cmd.ExecuteReader()

Dim Book As New XLS.Book
Dim fl As String = "c:\reports\test.xlsx" 
Book.Save(fl)

Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As Xls.Style = Book.NewStyle 
Style.BackColor = Color.Red

For c As Integer = 0 To nms.Count - 1 
    Sheet(0, c).Value = nms(c)
Next
For r As Integer = 0 To dt.DataRows.Count - 1 
    For c As Integer = 0 To nms.Count - 1 
        Sheet(r + 1, c).Value = dt.DataRows(r)(nms(c))
    Next
Next
'打开工作簿
Book = New XLS.Book(fl)

Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2023/4/29 10:28:00 [只看该作者]

Dim dt As DataTable = cmd.ExecuteReader()

Dim Book As New XLS.Book
Dim fl As String = "c:\reports\test.xlsx" 
Book.Save(fl)
'重新打开工作簿
Book = New XLS.Book(fl)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As Xls.Style = Book.NewStyle 
Style.BackColor = Color.Red

For c As Integer = 0 To nms.Count - 1 
    Sheet(0, c).Value = nms(c)
Next
For r As Integer = 0 To dt.DataRows.Count - 1 
    For c As Integer = 0 To nms.Count - 1 
        Sheet(r + 1, c).Value = dt.DataRows(r)(nms(c))
    Next
Next

Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
Proc.Start()

 回到顶部