我正在为用户输入的特定Invoice No
生成水晶报告。 Crystal报表第一次在exported
PDF
成功SampleInvoice.pdf
但是当我同时生成另一个Crystal报表时,新报表未获得Exported
和SampleInvoice.pdf
保持不变。
这是我生成Crystal Report的方式
SqlConnection con = new SqlConnection("Data source=.;Initial catalog=InvoiceSystem;user id =sa;password=rfm");
con.Open();
// string query = "Select * from tblInvoice";
SqlDataAdapter da = new SqlDataAdapter("sp_Report", con);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
da.SelectCommand.Parameters.Add("@InvoiceNo", SqlDbType.Int).Value = txtInvoice.Text;
con.Close();
InvoiceDataSet DS = new InvoiceDataSet();
da.Fill(DS, "tblInvoice");
con.Close();
rpt.Load(Server.MapPath("~/CrystalReport3.rpt"));
rpt.SetDataSource(DS);
CrystalReportViewer1.ReportSource = rpt;
ExportPDf();
这就是我导出PDF的方式
string filepath = "E:\\SampleInvoice.pdf";
public void ExportPDf()
{
ExportOptions CrExportOptions;
DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions();
PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions();
CrDiskFileDestinationOptions.DiskFileName = filepath;
CrExportOptions = rpt.ExportOptions;//Report document object has to be given here
CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions;
CrExportOptions.FormatOptions = CrFormatTypeOptions;
rpt.Export();
}
有没有办法在我生成另一张PDF后立即清除它?