For many years we have been creating Excel 2003 XML spreadsheets and sending them to our clients though a http.Response stream. Which would open Excell 2010 on their machines, and all was good. We are now being updated to Windows 10 and excel 2016, and Web pages and excell 2003 XML spreadsheets are being blocked. We have hundreds of reports to rewrite with no time available. I was hoping to use Aspose.cells to read the XML spreadsheets from a stream and write a xlsx file to a stream. See the code below. There are no errors, but the only thing in the files is: “Evaluation Only. Created with Aspose.Cells for .Net. Copyright 2003 - 2018 Aspose Pty Ltd” Should my data have been there if I was successful, or am I doing something wrong? Any help is appreciated.
Thanks
Bob
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Try
Dim nominationsDataTable As DataTable = Session(Common.sessionStateAwardNominationsString)
Dim spreadSheetString As String = Common.BuildNominationsSpreadSheet(nominationsDataTable)
Dim currentDateString As String = Microsoft.VisualBasic.Format(Now, "yyyy_MM_dd")
Dim fileNameString As String = "Nominations_" & currentDateString & ".xlsx"
'Response.Write(spreadSheetString)
Dim bufferBytes() As Byte = System.Text.Encoding.UTF8.GetBytes(spreadSheetString)
Dim inMemoryStream As New MemoryStream(bufferBytes)
Dim outMemoryStream As MemoryStream = New MemoryStream
'Read Spreadsheet from Stream
inMemoryStream.Position = 0
Dim loadOptions As New LoadOptions(LoadFormat.SpreadsheetML)
Dim workbook As New Workbook(inMemoryStream, loadOptions)
'Write Spreadsheet to Stream
Dim xSaveOptions As New XlsSaveOptions(SaveFormat.Xlsx)
workbook.Save(outMemoryStream, xSaveOptions)
outMemoryStream.Position = 0
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("content-disposition", "attachment; filename=" + fileNameString)
Response.BinaryWrite(outMemoryStream.ToArray())
Response.Flush()
Response.End()
inMemoryStream.Close()
outMemoryStream.Close()
Catch ex As Exception
Common.WriteToErrorLog(myWeb, "NominationsExcel: " & ex.Message & " - " & ex.StackTrace)
End Try
End Sub
.