Hi,
Exporting webgrid data in to excel previously working fine in my site.
But after adding gzip compression utility in my site, Exported data get damaged.
Please give me the suggestions.
Thanks in advance.
Hello,
You can use gzip settings and disable compression only of export.
Thanks.
Hi Ivan,
Thank you for reply.
but how can i disable compression only of export?
do you have any sample code?
On button click i export the grid data in excel. for e.g. UltraWebGridExcelExporter1.Export(UltraWebGrid1)
Protected Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As System.EventArgs)
Dim acceptEncoding As String = app.Request.Headers("Accept-Encoding")
If Not (TypeOf app.Context.CurrentHandler Is Page) OrElse app.Request("HTTP_X_MICROSOFTAJAX") IsNot Nothing Then
Return
End If
If acceptEncoding Is Nothing OrElse acceptEncoding.Length = 0 Then
acceptEncoding = acceptEncoding.ToLower()
If acceptEncoding.Contains("deflate") OrElse acceptEncoding = "*" Then
' defalte
app.Response.Filter = New DeflateStream(prevUncompressedStream, CompressionMode.Compress)
app.Response.AppendHeader("Content-Encoding", "deflate")
ElseIf acceptEncoding.Contains("gzip") Then
' gzip
app.Response.Filter = New GZipStream(prevUncompressedStream, CompressionMode.Compress)
app.Response.AppendHeader("Content-Encoding", "gzip")
End Sub
Some technical information about the export can be found here:
http://forums.infragistics.com/forums/p/11633/44048.aspx#44048
Maybe you can use the application/ms-excel MIME type of the exporting (downloading) operation and check for it in global.asax.
Hi Rumen,
Thanks. Before sending the webgrid for export to excel. change the Response.Contenttype. and in global.asax file check the content type and change the setting of compression type.
It works fine for me.
Thanks
vaibhavgg,
I know it's been 5 months, but any chance you can share your changes (ie the code)? We are having the same issue and this is the last of the bugs with GZIP. Also, have you noticed similiar with the document exporter and PDF's.
Thanks in advance for your help.
Great - thanks for sharing the solution in public forums, much appreciated. I will add this to the list of known potential problems, since I am sure a lot of people will find this useful.
Thanks again.