以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- excel模板问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=150711) |
-- 作者:nbsugu_z -- 发布时间:2020/6/5 13:48:00 -- excel模板问题 Dim Book As New XLS.Book(ProjectPath & "Attachments\\水电费结算单.xlsx") \'打开模板 Dim fl As String = ProjectPath & "Reports\\水电费结算单.pdf" Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim str1 As Integer = e.Form.Controls("ComboBox1").Value \'选年份 Dim str2 As Integer = e.Form.Controls("ComboBox2").Value \'选月份 Dim str3 As String = e.Form.Controls("ComboBox3").Value \'选单位 Dim Filter As String = "[yy] = " & str1 & " and [yy1] = " & str2 & " and [khbh] = \'" & str3 & "\'" If Filter IsNot Nothing Then Dim dr2 As Double = DataTables("wy_cpd").Compute("Sum(jsje)", Filter) Dim dr3 As Double = DataTables("wy_dgt").Compute("Sum(tje)", Filter) Dim dr4 As Double = DataTables("wy_dgd").Compute("Sum(je)", Filter) Dim dr5 As Double = DataTables("wy_cps").Compute("Sum(jsje)", Filter) Dim dr6 As Double = DataTables("wy_sgt").Compute("Sum(tje)", Filter) Dim dr7 As Double = DataTables("wy_sgd").Compute("Sum(je)", Filter) Dim dr8 As Double = DataTables("wy_wgd").Compute("Sum(je)", Filter) Sheet(7,10).Value = dr2+dr3+dr4 \'写年 Sheet(11,10).Value = dr5+dr6+dr7 \'写年 Sheet(13,10).Value = dr8 \'写年 Sheet(14,10).Value = dr2+dr3+dr4+dr5+dr6+dr7+dr8 \'写年 Sheet(2,8).Value = str1 & "年"& str2 & "月" \'写年 End If Sheet(4,11).Value = "< yy = " & str1 & " and yy1 = " & str2 & ">" \'写年 Sheet(5,11).Value = "< yy = " & str1 & " and yy1 = " & str2 & ">" \'写年 Sheet(6,11).Value = "< yy = " & str1 & " and yy1 = " & str2 & ">" \'写年 Sheet(8,11).Value = "< yy = " & str1 & " and yy1 = " & str2 & ">" \'写年 Sheet(9,11).Value = "< yy = " & str1 & " and yy1 = " & str2 & ">" \'写年 Sheet(10,11).Value = "< yy = " & str1 & " and yy1 = " & str2 & ">" \'写年 Sheet(12,11).Value = "< yy = " & str1 & " and yy1 = " & str2 & ">" \'写年 Book.Build() \'生成报表 Book.SaveToPDF(fl) Dim Proc As New Process Proc.File = fl Proc.Start() 老师 以上代码是否有错?发布后打印PDF时, 提示:无法保存该文档。该文档可能已被打开,或者保存时出错! 确定后又提示 异常来自 HRESULT:0x800A03EC 在没有发布开发时,运行正常。发布后就有问题。我是在同一台电脑开发,并运行的
[此贴子已经被作者于2020/6/5 14:34:00编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/6/5 14:11:00 -- http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=50080 在发布后的publish\\project\\目录里手工添加一个“Reports”文件夹,再复制到其它电脑使用。或者使用代码添加目录;或者指定到一个存在的路径,比如:Dim fl As String = ProjectPath & "水电费结算单.pdf"
|
-- 作者:nbsugu_z -- 发布时间:2020/6/5 14:33:00 -- 好了,谢谢,原来如此。不过还有个问题,后台excel 打开过的表永远存在,如何消除掉呢?当我打开其它EXCEL文件时,模板生成的EXCEL文件会跳出来。 |
-- 作者:有点蓝 -- 发布时间:2020/6/5 14:50:00 -- 这个是execl自己进程管理的问题,我们控制不了 |