Page output while processing file

I’m looking to send status updates to the browser window while the
excel file is processing via response.flush. When I try the follwoing
code:



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Call CreateReport()

End Sub



Public Sub CreateReport()

Dim i As Integer



Dim license As Aspose.Cells.License = New Aspose.Cells.License

'Pass only the name of the license file embedded in the assembly

license.SetLicense(“Aspose.Cells.lic”)

Dim path As String = AppSettings(“templatesFolder”) & “test.xls”

Dim workbook As Workbook = New Workbook

workbook.Open(path)

Dim sheets As Worksheets = workbook.Worksheets

Dim cells As Cells = workbook.Worksheets(0).Cells



Dim myConnection As New SqlConnection(AppSettings(“ConnectionString”))

Dim myCommand As SqlDataAdapter

Dim myDataSet As New DataSet



myCommand = New SqlDataAdapter(“exec usp_getUsers”, myConnection)

myCommand.Fill(myDataSet)



output.Text = “processing”

If myDataSet.Tables(0).Rows.Count > 0 Then

For i = 0 To myDataSet.Tables(0).Rows.Count - 1

cells(i,
0).PutValue(myDataSet.Tables(0).Rows(i).Item(“userName”).ToString())

Next

End If

'userName



output.Text = “processing complete”

Response.Flush()



workbook.Save(“report.xls”,
SaveType.OpenInExcel, FileFormatType.Default, Me.Response)



End Sub



I receive this error:

Server cannot set content type after HTTP headers have been sent.



Is there another way to accomplish this?


When calling Workbook.Save method, Aspose.Cells will change the content type. So please comment out this line of code:

'Response.Flush()