Foxtable(狐表)用户栏目专家坐堂 → 求助:生成Word报表问题


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

主题:求助:生成Word报表问题

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/7 10:46:00 [显示全部帖子]

Dim t As Table = Tables("日报表")
If t.rows.count > 0 Then
    Dim tm As String  = ProjectPath & "Attachments\test.doc" '指定模板文件
    Dim fl As String = ProjectPath & "Reports\练习.doc" '指定目标文件
    Dim wrt As New WordReport(Tables("日报表"),tm,fl) '定义一个WordReport
    Dim sum1 As Double = DataTables("日报表").Compute("Sum(资金可用余额)","日期 = #" & Date.Today & "#")
    Dim sum2 As Double = DataTables("日报表").Compute("Sum(当天收入截至当天17时_现金回款额)","日期 = #" & Date.Today & "#")
    Dim sum3 As Double = DataTables("日报表").Compute("Sum(支出合计)","日期 = #" & Date.Today & "#")
   
    Dim str As String = "当日资金可用余额总计: " & sum1 & "万元,截至当日17时回款总计:" & Sum2 & "万元,当日支出总计" & sum3 & "万元"
    wrt.Replace("[第一部分]", str)
    str = ""
    Dim i As Integer = 1
    For j As Integer = t.TopPosition To t.BottomPosition
        Dim dr As Row = t.rows(j)
        str &= i & "?" & dr("项目名称") & ":(1)当日资金可用余额:" & Format(dr("资金可用余额") ,"0.00") & "万元;"
        str &= vbcrlf
        i += 1
    Next
    wrt.Replace("[第二部分]", str)
    wrt.Build
    wrt.Show() '显示报表
end if

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/7 11:54:00 [显示全部帖子]

代码没问题,上传实例说明问题。

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/7/7 14:41:00 [显示全部帖子]

改一改

 

'''
Dim t As Table = Tables("日报表")
If t.rows.count > 0 Then
    Dim tm As String  = ProjectPath & "Attachments\test.doc" '指定模板文件
    Dim fl As String = ProjectPath & "Reports\练习.doc" '指定目标文件
    Dim wrt As New WordReport(Tables("日报表"),tm,fl) '定义一个WordReport
    Dim sum1 As Double = DataTables("日报表").Compute("Sum(资金可用余额)","日期 = #" & Date.Today & "#")
    Dim sum2 As Double = DataTables("日报表").Compute("Sum(当天收入截至当天17时_现金回款额)","日期 = #" & Date.Today & "#")
    Dim sum3 As Double = DataTables("日报表").Compute("Sum(支出合计)","日期 = #" & Date.Today & "#")
   
    Dim str As String = "当日资金可用余额总计: " & sum1 & "万元,截至当日17时回款总计:" & Sum2 & "万元,当日支出总计" & sum3 & "万元"
    wrt.Replace("[第一部分]", str)
    str = ""
    Dim i As Integer = 1
    For j As Integer = t.TopPosition To t.BottomPosition
        Dim dr As Row = t.rows(j)
        str &= i & "、" & dr("项目名称") & ":(1)当日资金可用余额:" & Format(dr("资金可用余额") ,"0.00") & "万元;"
        str &= vbcrlf
        i += 1
    Next
    wrt.Replace("[第二部分]", str)
    wrt.BuildOne(t.Current.DataRow)
    wrt.Show() '显示报表
End If


 回到顶部