I’m trying to save a simple “hello world” workbook to an HttpResponse, but always get an exception.
My code is:
Dim wb As New Workbook() Dim sheet As Worksheet = wb.Worksheets(0) Dim cell As Cell = sheet.Cells(“A1”) cell.PutValue(“Hello World!”) wb.Save(“Test.xls”, FileFormatType.Default, SaveType.OpenInBrowser, Response)
all in a button click event handler.
but this gives the exception:
"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near ‘’"
This is using the evaluation version of Aspose.cells v4.4.0.5 for .NET 2.0.
Well, I tested your code and it works fine. I don't find any problem running on .NET 2.0. Do you use some sort of Http Compression or other utilities/settings on IIS.
Could you try the following code:
Dim wb As New Workbook() Dim sheet As Worksheet = wb.Worksheets(0) Dim cell As Cell = sheet.Cells("A1") cell.PutValue("Hello World!") Dim stream As MemoryStream = New MemoryStream() wb.Save(stream, FileFormatType.Default) response.ContentType = "application/vnd.ms-excel" 'This is same as OpenInBrowser option response.AddHeader( "content-disposition","inline; filename=Test.xls"); response.BinaryWrite(stream.ToArray()) response.End()
in this function from ScriptResource.axd - (whatever that it)
function Sys$Net$XMLHttpExecutor$get_responseData() { /// if (arguments.length !== 0) throw Error.parameterCount(); if (!this._responseAvailable) { throw Error.invalidOperation(String.format(Sys.Res.cannotCallBeforeResponse, ‘get_responseData’)); } if (!this._xmlHttpRequest) { throw Error.invalidOperation(String.format(Sys.Res.cannotCallOutsideHandler, ‘get_responseData’)); } return this._xmlHttpRequest.responseText; }
The error occurs on the red line.
I’ve just looked through IIS, and can see that there is a Compression ISAPI Filter installed. I’ve just removed it, but still get the same problem with my original code.
BTW, One of those links suggested this was an IE6 problem, but a colleague just tested my original code in IE7, and got the same exception.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.