Foxtable(狐表)用户栏目专家坐堂 → [求助] 用代码生成的Excel,第一列不见了


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

主题:[求助] 用代码生成的Excel,第一列不见了

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


加好友 发短信
等级:六尾狐 帖子:1348 积分:9833 威望:0 精华:0 注册:2015/6/30 8:46:00
[求助] 用代码生成的Excel,第一列不见了  发帖心情 Post By:2018/3/30 10:16:00 [只看该作者]

Dim tb As Table = Tables(e.Form.Name & "_Table5")
Dim dt As DataTable = tb.DataTable
Dim r As Row = tb.Current
Dim d As Date = Functions.Execute("返回服务器日期")
Dim lj As String = "d:\采购订单模板\" &  " _ "  & d.Year & "_" &   d.Month & "_" &  d.Day & "\"


Dim Book As New XLS.Book(ProjectPath & "Attachments\123.xls") '打开模板
Dim fl1 As String =  lj & "Reports\" & r("采购订单号") & "_采购订单.xls"
Dim fl As String = lj & r("采购订单号") & "_采购订单.xls"

Dim Sheet As XLS.Sheet = Book.Sheets(0)

For ri As Integer = 0 To tb.Rows.Count - 1
    For ci As Integer = 0 To tb.Cols.Count - 1
        MessageBox.Show(sheet(1,ci).value & "|" & tb.Cols(ci).Name)
        sheet(ri + 2,ci).value = tb.rows(ri)(tb.Cols(ci).Name)
    Next
Next

Book.Build() '生成报表
Book.Save(fl)

图片点击可在新窗口打开查看此主题相关图片如下:无标题.png
图片点击可在新窗口打开查看






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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/3/30 10:26:00 [只看该作者]

方法一:

 

For ri As Integer = 0 To tb.Rows.Count - 1
    For ci As Integer = 0 To tb.Cols.Count - 1
        MessageBox.Show(sheet(1,ci).value & "|" & tb.Cols(ci).Name)
        sheet(ri + 2,ci+1).value = tb.rows(ri)(tb.Cols(ci).Name)
    Next
Next
 
方法二:你不需要build的吧?拷贝一份模板,然后直接写入,把Book.Build()删除即可。

 回到顶部