方法1、在页面提供多个按钮给用户,一个按钮下载一个文件,比如 With wb.AddButtonGroup("form1","btg1",True) '垂直排列
.Add("btn1", "文件1", "", "emp.xls")
.Add("btn2", "文件2", "", "emp2.xls")
.Add("btn3", "文件3", "", "emp3.xls")
End With
要注意服务端是多个用户共用的,所以应该根据登录用户专门建一个目录使用,比如张三登录,就在web根目录建一个张三的目录,把报表文件生成到这个张三目录里再压缩
大概
Case "emp.xls" '下载为文件
dim dir as string = "d:\web\" & e.Cookies("username") & "\" & format(date.today,"yyyyMMdd")
If FileSys.DirectoryExists(dir)=false Then
FileSys.DeleteDirectory(dir,2,3)
FileSys.CreateDirectory(dir)
End If
For Each dr As DataRow In drs
Dim Book As New XLS.Book(ProjectPath & "Attachments\资料卡.xls")
book.AddDataTable("员工","数据源名称","Select * from {员工} where 姓名 = '“”name“”'")
book.build()
Book.Save(dir & "\" & name &".xls" )
next
If FileSys.FileExists(dir & ".zip") Then
FileSys.DeleteFile(dir & ".zip",2,2)
End If
Dim zip As New zipFile
zip.Create(dir & ".zip")
zip.AddFolder(dir )
zip.Close()
e.WriteFile(dir & ".zip")