asp.net 导出pdf
//-------------------导出pdf----------------------------------------------------------------------------------
private void ExportReportDataToPdf()
{
//需要去下载dll
CrystalDecisions.CrystalReports.Engine.ReportDocument RptDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
CrystalDecisions.Shared.DiskFileDestinationOptions crFileOptions = new CrystalDecisions.Shared.DiskFileDestinationOptions();
string Year = DateTime.Now.Year.ToString();//年份
string Month = DateTime.Now.Month.ToString();//月份
string Day = DateTime.Now.Day.ToString();//日
string Hour = DateTime.Now.Hour.ToString();//小时
string Minute = DateTime.Now.Minute.ToString();//分钟
string Timestring = Year + "-" + Month + "-" + Day + "-" + Hour + "-" + Minute;
string fileName = strRefNo + "-" + Timestring + ".pdf";
string fileFullName = ConfigurationManager.AppSettings["AWOutputForStyle"] + CompanyName + "\\";
if (!Directory.Exists(fileFullName)) Directory.CreateDirectory(fileFullName); //表示创建目录
crFileOptions.DiskFileName = fileFullName + fileName;
string PILocation = fileFullName + fileName;
//加载报表
DataSet ds = BllLibrary.GetOrderInvoiceData(strRefNo);
RptDoc.Load(Server.MapPath("~/Reports/OrderInvoice2.rpt"));//载入时候的报表文件
RptDoc.Subreports["SizeLabel"].SetDataSource(ds.Tables[1]);
//RptDoc.OpenSubreport("SizeLabel");
RptDoc.Subreports["Style Season"].SetDataSource(ds.Tables[2]);
//RptDoc.OpenSubreport("Style Season");
RptDoc.SetDataSource(ds.Tables[0]);
RptDoc.ExportOptions.DestinationOptions = crFileOptions;
RptDoc.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;
RptDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
RptDoc.Export();
}