Foxtable(狐表)用户栏目专家坐堂 → 服务端使用excel报表的问题


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

主题:服务端使用excel报表的问题

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


加好友 发短信
等级:狐精 帖子:3370 积分:24858 威望:0 精华:0 注册:2012/3/26 21:47:00
服务端使用excel报表的问题  发帖心情 Post By:2022/4/25 10:24:00 [显示全部帖子]

在服务端使用下列代码生成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

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


加好友 发短信
等级:狐精 帖子:3370 积分:24858 威望:0 精华:0 注册:2012/3/26 21:47:00
  发帖心情 Post By: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()

 回到顶部