我正在编写一个 .net Web 服务来下载使用免费版 GemBox.Spreadsheet 创建的 excel 文件。调用服务,服务器运行但没有给出任何答案。这是代码。任何想法(或另一个图书馆)?谢谢
'''
<WebMethod(EnableSession:=True)>
Public Sub Download()
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
Dim workbook As New ExcelFile()
Dim worksheet = workbook.Worksheets.Add("Hello World")
worksheet.Cells(0, 0).Value = "English:"
worksheet.Cells(0, 1).Value = "Hello"
worksheet.Cells(1, 0).Value = "Russian:"
worksheet.Cells(2, 0).Value = "Chinese:"
Dim options As SaveOptions = SaveOptions.XlsDefault
Dim filename As String = "TestFile.xls"
Using stream As New MemoryStream
workbook.Save(stream, options)
worksheet.Clear()
worksheet = Nothing
workbook = Nothing
With System.Web.HttpContext.Current.Response
.ClearHeaders()
.ClearContent()
.Buffer = True
.ContentType = "application/vnd.ms-excel"
.AddHeader("content-disposition", "attachment; filename=" + filename)
.AppendHeader("Content-Length", stream.Length)
stream.CopyTo(.OutputStream)
.End()
End With
End Using
End Sub
'''