Crystal报告临时文件,删除c#表单中关闭按钮的代码。 如何清除报告缓存? 在此先感谢。
答案 0 :(得分:0)
此链接确实对我有帮助。试试吧
http://www.pedautreppe.com/post/Crystal-Reports-generates-temporary-files.aspx
private void Page_Unload(object sender, EventArgs e)
{
CloseReports(cr);
cr.Dispose();
CrystalReportViewer1.Dispose();
CrystalReportViewer1 = null;
}
private void CloseReports(ReportDocument reportDocument)
{
Sections sections = reportDocument.ReportDefinition.Sections;
foreach (Section section in sections)
{
ReportObjects reportObjects = section.ReportObjects;
foreach (ReportObject reportObject in reportObjects)
{
if (reportObject.Kind == ReportObjectKind.SubreportObject)
{
SubreportObject subreportObject = (SubreportObject)reportObject;
ReportDocument subReportDocument = subreportObject.OpenSubreport(subreportObject.SubreportName);
subReportDocument.Close();
}
}
}
reportDocument.Close();
}
全局打开报告并在页面内全局关闭它。这将有所帮助