以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 报表模板后台统计表达式 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=127595) |
-- 作者:aza520 -- 发布时间:2018/11/17 17:03:00 -- 报表模板后台统计表达式 我在EXCEL报表模板的单元格里设了以下表达式,我”零号清单“表是分页加载的,共有两页,”图纸金额“列是表达式列,以下公式只汇总出第一页的数量,请问老师怎么修改? [$零号清单,Sum(图纸金额),章节 = \'800\']
|
-- 作者:有点蓝 -- 发布时间:2018/11/17 17:05:00 -- 参考:http://www.foxtable.com/webhelp/scr/1496.htm |
-- 作者:aza520 -- 发布时间:2018/11/17 17:07:00 -- 我生成报表的代码如下: Dim Book As New XLS.Book(ProjectPath & "Attachments\\中期支付证书.xlsx") Dim fl As String = ProjectPath & "Reports\\中期支付证书.xlsx" book.AddDataTable("中期支付证书","xlgl","Selec t * ,(Case When 图纸数量 Is null Then 0 Else 图纸数量 End) * (Case When 单价 Is null Then 0 Else 单价 End) As [图纸金额] fro m {零号清单} " & IIF(DataTables("零号清单").LoadFilter > ""," where " & DataTables("零号清单").LoadFilter,"")) Book.Build() Book.Save(fl) Dim Proc As New Process Proc.File = fl Proc.Start() |
-- 作者:有点蓝 -- 发布时间:2018/11/17 17:24:00 -- 有什么问题? |
-- 作者:aza520 -- 发布时间:2018/11/17 17:32:00 -- 应该是代码的问题,我把代码改成以下,红字部分不对,但不知怎么改 Dim Book
As New XLS.Book(ProjectPath & "Attachments\\中期支付证书.xlsx") Dim fl
As String = ProjectPath & "Reports\\中期支付证书.xlsx" Dim filter
As String = IIF(vars("计量汇总filter") > ""," where " &
vars("计量汇总filter") & ") book.AddDataTable("中期支付证书","xlgl","Selec t
*, (select sum(Round(Case When 图纸数量 Is null Then 0
Else 图纸数量 End * Case When 单价 Is null Then 0
Else 单价 End,0)) fro m {零号清单} b where a.项目名称=b.项目名称 and a.施工合同段=b.施工合同段)
As [图纸金额] fro m {零号清单} a " & filter) Book.Build() Book.Save(fl) Dim Proc As New Process Proc.File = fl Proc.Start() |
-- 作者:有点蓝 -- 发布时间:2018/11/17 17:39:00 -- Dim filter As String = IIF(vars("计量汇总filter") > ""," where " & vars("计量汇总filter"),"") select a.*,b.图纸金额 from {零号清单} as a inner join (select 项目名称,施工合同段,sum(图纸数量 * 单价) as 图纸金额 from {零号清单} group by 项目名称,施工合同段) as b on a.项目名称=b.项目名称 and a.施工合同段=b.施工合同段
|
-- 作者:aza520 -- 发布时间:2018/11/17 17:50:00 -- 老师,后面这名代码能否提供个完整的,象这样 book.AddDataTable("中期支付证书","xlgl","Selec t *, (select sum(Round(Case When 图纸数量 Is null Then 0 Else 图纸数量 End * Case When 单价 Is null Then 0 Else 单价 End,0)) fro m {零号清单} b where a.项目名称=b.项目名称 and a.施工合同段=b.施工合同段) As [图纸金额] fro m {零号清单} a " & filter)
|
-- 作者:有点甜 -- 发布时间:2018/11/18 21:47:00 --
把sql语句,直接替换你原来的sql语句即可啊。
|
-- 作者:aza520 -- 发布时间:2018/11/19 9:22:00 -- 老师,以下代码还是只能统计当前页的数据,其它加载页的数据统计不了 Dim Book As New XLS.Book(ProjectPath & "Attachments\\中期支付证书.xlsx") Dim fl As String = ProjectPath & "Reports\\中期支付证书.xlsx" Dim filter As String = IIF(vars("计量汇总filter") > ""," where " & vars("计量汇总filter"),"") book.AddDataTable("中期支付证书","xlgl","selec t a.*,b.图纸金额 fro m {零号清单} as a inner join (select 项目名称,施工合同段,sum(图纸数量 * 单价) as 图纸金额 fro m {零号清单} group by 项目名称,施工合同段) as b on a.项目名称=b.项目名称 and a.施工合同段=b.施工合同段") Book.Build() Book.Save(fl) Dim Proc As New Process Proc.File = fl Proc.Start() |
-- 作者:有点甜 -- 发布时间:2018/11/19 9:25:00 -- 在sql测试窗口测试你的sql语句,看查找到的数据是否正确
http://www.foxtable.com/webhelp/scr/1484.htm
如果自己不会调试,做个实例发上来测试 |