私は、私は、ユーザーが自分のReport.aspx
ページにGet Data
ボタンをクリックしたときにDevExpressASPxGridViewExporter
とASPxGridView
を使用してxls
かcsv
ファイルにエクスポートするダイナミック列を持ついくつかのSQLのテーブルを持っています。なぜDevExpressを使用してファイルにデータをエクスポートするとZlibExceptionがスローされるのですか?
- テーブルが真のデータに成功
- ページの負荷で正しく行われ、真に
私の問題
ユーザーがボタンをクリックすると、それは次のようで破損したファイルをダウンロードしたデータを示していますコンテンツ、
私は、検索しましたgoogle,stackoverflow,microsoft support、devexpress supportなど多くのサイトがありましたが、回答はありませんでした。
ご協力いただきますようお願い申し上げます。
Server Error in '/' Application.
The stream state of the underlying compression routine is inconsistent.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.Compression.ZLibException: The stream state of the underlying compression routine is inconsistent.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ZLibException: The stream state of the underlying compression routine is inconsistent.]
System.IO.Compression.DeflaterZLib.Deflate(FlushCode flushCode) +196
System.IO.Compression.DeflaterZLib.ReadDeflateOutput(Byte[] outputBuffer, FlushCode flushCode, Int32& bytesRead) +185
System.IO.Compression.DeflaterZLib.System.IO.Compression.IDeflater.GetDeflateOutput(Byte[] outputBuffer) +44
System.IO.Compression.DeflateStream.WriteDeflaterOutput(Boolean isAsync) +58
System.IO.Compression.DeflateStream.Write(Byte[] array, Int32 offset, Int32 count) +76
System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr) +578
System.Web.HttpResponse.UpdateNativeResponse(Boolean sendHeaders) +1272
System.Web.HttpResponse.Flush(Boolean finalFlush, Boolean async) +191
System.Web.HttpWriter.WriteFromStream(Byte[] data, Int32 offset, Int32 size) +88
System.IO.Compression.DeflateStream.PurgeBuffers(Boolean disposing) +142
System.IO.Compression.DeflateStream.Dispose(Boolean disposing) +40
System.IO.Stream.Close() +26
System.IO.Compression.GZipStream.Dispose(Boolean disposing) +42
System.IO.Stream.Close() +26
System.Web.HttpWriter.FilterIntegrated(Boolean finalFiltering, IIS7WorkerRequest wr) +767
System.Web.HttpResponse.FilterOutput() +127
System.Web.CallFilterExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +62
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +98
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0
私の質問
- なぜ
ZLibException
thorws?ここで
私のコードです:
ASP
<%@ Register Assembly="DevExpress.Web.v16.1" Namespace="DevExpress.Web"
TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.XtraPrinting.v16.1" Namespace="DevExpress.Web"
TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Printing.v16.1.Core, Version=16.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Printing"
TagPrefix="dx" %>
<asp:Content ID="Content2" ContentPlaceHolderID="C" runat="Server">
<div id="divMain" class="main" style="padding: 10px">
<asp:ObjectDataSource ID="ods" runat="server" TypeName="MySite.Control.CustomTable" SelectMethod="ReadTable">
<SelectParameters>
<asp:Parameter Type="Int64" Name="ID" />
</SelectParameters>
</asp:ObjectDataSource>
<dx:ASPxGridView ID="grid" runat="server" ClientInstanceName="grid" AutoGenerateColumns="false"
KeyFieldName="ID" Width="100%">
<Columns>
<!-- Columns Will Be Generated Dynamically -->
</Columns>
<SettingsCustomizationWindow Enabled="True" />
<SettingsBehavior ColumnResizeMode="Control" AllowDragDrop="true" AllowFocusedRow="true" />
<Settings ShowGroupPanel="True" ShowColumnHeaders="true" ShowFilterBar="Visible"
ShowFooter="true" ShowGroupFooter="VisibleIfExpanded" ShowGroupButtons="true"
ShowFilterRow="true" ShowFilterRowMenu="true" />
<SettingsLoadingPanel Mode="ShowOnStatusBar" />
<GroupSummary>
</GroupSummary>
</dx:ASPxGridView>
<!-- ASPxGridViewExporter -->
<dx:ASPxGridViewExporter ID="exporter" runat="server" GridViewID="grid">
</dx:ASPxGridViewExporter>
<div style="direction: rtl">
<asp:DropDownList ID="exportType" runat="server">
<asp:ListItem Text="XLS" Value="XLS" />
<asp:ListItem Text="CSV" Value="CSV" />
</asp:DropDownList>
<asp:Button ID="btnExport" runat="server" Text="Get Data" OnClick="BtnExportClick" />
</div>
</div>
</asp:Content>
C#
protected void BtnExportClick(object sender, EventArgs e)
{
grid.SettingsDetail.ExportMode = GridViewDetailExportMode.All;
switch (exportType.SelectedValue)
{
case "XLS":
exporter.WriteXlsToResponse();
break;
case "CSV":
exporter.WriteCsvToResponse();
break;
default:
return;
}
}