を実行せず。パラメータをロードし、レポートをロードするファイル名/パスを取得すると、すべてが正しく実行されているようです。しかし、私はポップアップダイアログボックスを作成すると思われる部分を実行すると、ユーザーに保存、実行、ダウンロードのいずれのタイプのキャンセルも行われません。エラーはスローされません。私が知っているコードのどこかを踏んでいるわけではありません。それはExportToHttpResponse行を実行し、それから何もしないようです。ExportToHttpResponse Crystalレポートだから私は</p> <blockquote> <p>ExportToHttpResponse</p> </blockquote> <p>方法を使用して自分のWebアプリケーションの実行時ビューアでレポートを開くことなくPDFにCrystalレポートをエクスポートしようとしていますCRViewer
だから私は、誰かが私に私がコードで間違っていることができるもので、いくつかの方向性を与えることができる期待していた以下のが見つかりました:
protected void ExportRptButton_Click(object sender, EventArgs e)
{
if (null != SelectedReport)
{
rptParams.Clear();
rptParams = null;
// Get the report document
// string filePath = Server.MapPath(@"~\Reports\" + SelectedReport.FileName + ".rpt");
// Declare a new Crystal Report Document object and load the report file into the report document.
ReportDocument rptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ConfigureCrystalReports(rptDoc);
// repDoc.Load(rptFileName);
// AddParameters();
// Set the report parameters the report object.
LoadParameterFields(rptDoc);
// Set the static text fields in the report object.
LoadStaticTextFields(rptDoc);
try
{
if (rptDoc.IsLoaded)
{
// Stop buffering the response
Response.Buffer = false;
// Clear the response content and headers
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
// Export the Report to Response stream in PDF format and file name Customers
rptDoc.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "DirectAccessReport");
// rptDoc.ExportToDisk(ExportFormatType.PortableDocFormat, "~/PDF_Folder");
// There are other format options available such as Word, Excel, CVS, and HTML in the ExportFormatType Enum given by crystal reports
}
}
catch (Exception ex)
{
logger.ErrorFormat("Could not export to pdf! {0}", ex);
}
}
}
いくつかの注意:LoadParametersFieldsを/上に表示さLoadStaticTextFields方法が働いているように見えます正しく、crviewerでレポートを開くために使用すると、レポートが表示され、機能します。しかし、あなたがそれらの方法を見たいと思っても私は要請に応じてそれらを投げるでしょう。
初めにrptParamsは個人的に宣言List<ReportParameter>()
ConfigureCrystalReportsメソッドはレポートのファイルパスを取得し、ロードするために使用されています。
ご意見やご提案をいただければ幸いです。ありがとうございました。
てみてください;' 'rptDoc.ExportToHttpResponse' – Icarus
@Icarus後、私はそれを試してみましたが、それは任意の顕著な変化 – James213