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


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

主题:数据导出 导出数据不完整

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


加好友 发短信
等级:幼狐 帖子:76 积分:735 威望:0 精华:0 注册:2020/12/20 14:02:00
数据导出 导出数据不完整  发帖心情 Post By:2022/9/30 12:49:00 [只看该作者]

老师,帮忙看下代码,数据导出后 “置换指标性质” 列 数据导出不完整,部分行的该列有数据,但导出后为空白,您受累指导下

If Tables("销售订单结算窗口_Table2").rows.count > 0 Then
    Dim dt As Table = Tables("销售订单结算窗口_Table2")
    Dim nms() As String = {"销售顾问","客户姓名","电话号码","证件号码","身份证地址","订车日期","车型","配置","外观颜色","内饰颜色","VIN码","整车收入_裸车收入","整车收入_支付置换补贴","整车收入_收入合计","整车成本","返利合计","裸车利润","置换指标性质","二手车销售利润","上牌收入","上牌成本","出库费收入","上牌利润","装具收入","装具成本","装具利润","付款方式","贷款金融公司","贷款期数","贷款金额","贷款服务费收入","贷款利润","保险利润","边际利润","利润总额","fa piao类型","开piao日期","fa piao号","整车开piao价格","整车开piao差价","售车申报日期","结算日期"} '要导出的列名
    Dim caps() As String = {"销售顾问","客户姓名","电话号码","证件号码","身份证地址","订车日期","车型","配置","外观颜色","内饰颜色","VIN码","整车收入","支付置换补贴","整车收入合计","整车成本","返利合计","裸车利润","置换指标性质","二手车销售利润","上牌收入","上牌成本","出库费收入","上牌利润","装具收入","装具成本","装具利润","付款方式","贷款金融公司","贷款期数","贷款金额","贷款服务费收入","贷款利润","保险利润","边际利润合计","利润总额","fa piao类型","开piao日期","fa piao号","整车开piao价格","整车开piao差价","售车申报日期","结算日期"}  '对应的列标题
    Dim szs() As Integer = {70,100,110,170,300,90,90,250,90,90,190,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90} '对应的列宽
    Dim Book As New XLS.Book '定义一个Excel工作簿
    Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
    Dim st As XLS.Style = Book.NewStyle '日期列的显示格式
    st.Format = "yyyy-MM-dd"
    For c As Integer = 0 To nms.length -1
        Sheet(0, c).Value = caps(c) '指定列标题
        Sheet.Cols(c).Width = szs(c) '指定列宽
        If dt.Cols(nms(c)).IsDate Then '如果是日期列
            Sheet.Cols(c).Style = st '设置显示格式
        End If
    Next
    For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
        For c As Integer = 0 To nms.length -1
            Sheet(r +1, c).Value = dt.rows(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
Else
    MessageBox.Show("没有要导出的数据,请重试刷新")
    e.Cancel = True
End If

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


加好友 发短信
等级:超级版主 帖子:111393 积分:567029 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/9/30 13:38:00 [只看该作者]

代码没有问题。如果导出没有数据,说明Tables("销售订单结算窗口_Table2")表格本身就没有这些数据

 回到顶部