Foxtable(狐表)用户栏目专家坐堂 → 数据导出


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

主题:数据导出

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


加好友 发短信
等级:超级版主 帖子:111414 积分:567140 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/2/5 17:39:00 [显示全部帖子]

    Dim nms() As String = {"债权人","开户银行","银行账号","联系电话","身份证号码"} '要导出的列名
    Dim caps() As String = {"债权人","开户银行","银行账号","联系电话","身份证号码"} '对应的列标题
    Dim szs() As Integer = {100,120,120,150,200} '对应的列宽
    Dim Book As New XLS.Book '定义一个Excel工作簿
    Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
    For c As Integer = 0 To nms.length -1
        Sheet(0, c).Value = caps(c) '指定列标题
        Sheet.Cols(c).Width = szs(c) '指定列宽
    Next
dim ts as list(of row) = Tables("债权人基本情况表").GetCheckedRows
    For r As Integer = 0 To ts.Count - 1 '填入数据
        For c As Integer = 0 To nms.length -1
            Sheet(r +1, c).Value = ts(r)(nms(c))
        Next
    Next
    Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
    dlg.Filter= "Excel文件|*.xls" '设置筛选器
    If dlg.ShowDialog = DialogResult.Ok Then
        Book.Save(dlg.FileName)
        Dim Proc As New Process
        Proc.File = dlg.FileName
        Proc.Start()
    End If


 回到顶部