以文本方式查看主题 - 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=176736) |
-- 作者:rjh4078 -- 发布时间:2022/4/25 10:24:00 -- 服务端使用excel报表的问题 在服务端使用下列代码生成excel报表 发现内容是空白的 使用writebook又是正常的. 我的目的是想把excel报表转成图片发给客户端,不发送excel或者pdf文件, Dim wb As New weui Dim e As RequestEventArgs = args(0) Dim lj As String If e.GetValues("bjf")<>"" Then lj=ProjectPath & "Attachments\\" & e.GetValues("bjf") & "报价单.xlsx" If FileSys.FileExists(lj)=False Then With wb.AddMsgPage("","msgpage","操作失败","不能使用非约定报价单位!") .AddButton("btn1","返回","index.htm" ) .Icon="warn" End With e.WriteString(wb.Build) Return Nothing End If Dim Book As New XLS.Book(lj) book.AddDataTable("报价单","cderp","Sel ect * from {报价单} where 报价单号= \'" & e.GetValues("id") & "\'") book.AddDataTable("报价明细","cderp","Se lect * from {报价明细} where 报价单号= \'" & e.GetValues("id") & "\'") book.AddRelation("报价单","报价单号","报价明细","报价单号") \'e.WriteBookAsHTML(Book) \' e.WriteBookAsPDF(Book) Dim fl As String=ProjectPath & "web\\temp\\" & rand.NextString(12) & ".xlsx" Book.Build() Book.Save(fl) e.WriteFile(fl) End If |
-- 作者:有点蓝 -- 发布时间:2022/4/25 10:39:00 -- 请上传实例测试 |
-- 作者:rjh4078 -- 发布时间:2022/4/25 12:41:00 -- 有个比较魔幻的事情 下面代码在出问题的这个项目里,生成报表里面的数据是空的 我新建一个项目,同样的代码和模板文件就是正常的 Dim lj As String lj=ProjectPath & "Attachments\\报价单.xls" Dim Book As New XLS.Book(lj) book.AddDataTable("报价单","cderp","Sel ect * from {报价单} where 报价单号=\'000037\'") book.AddDataTable("报价明细","cderp","Se lect * from {报价明细} where 报价单号=\'000037\'") book.AddRelation("报价单","报价单号","报价明细","报价单号") \'e.WriteBookAsHTML(Book) \'\' e.WriteBookAsPDF(Book) Dim fl As String fl=lj.Replace("Attachments","Reports") Book.Build() Book.Save(fl) Dim Proc As New Process Proc.File = fl Proc.Start() |
-- 作者:有点蓝 -- 发布时间:2022/4/25 13:36:00 -- 这2个表是不是没有在外部表管理中添加进来? |