CrystalDecisions.Web.CrystalReportViewer CRtV1;
string strSql,strConnection;
SqlConnection objConnection=null;
SqlDataAdapter objAdapter=null;
DataSet objDataset=new DS1();
strConnection="server=killerwc;database=me;uid=sa;pwd=sophie.wang";
strSql="select * from V_Student_TrvNodeStudent";
objConnection=new SqlConnection(strConnection);
objAdapter=new SqlDataAdapter(strSql,objConnection);            
objAdapter.Fill (objDataset,"V_Student_TrvNodeStudent");
objConnection.Close();
CR3 oRpt=new CR3();//报表类名字
oRpt.SetDataSource(objDataset);
ExportOptions crOpt;
DiskFileDestinationOptions crDFDO;
string Fname="c:\\inetpub\\wwwroot\\CrystalReport\\a.pdf";
ExcelFormatOptions excelFormatOpts = new ExcelFormatOptions();
excelFormatOpts.ExcelTabHasColumnHeadings =true;
crDFDO=new DiskFileDestinationOptions();
crDFDO.DiskFileName=Server.MapPath(@"a.pdf") ;
crOpt=oRpt.ExportOptions;
crOpt.DestinationOptions=crDFDO;
crOpt.ExportDestinationType=ExportDestinationType.DiskFile;
crOpt.ExportFormatType=ExportFormatType.PortableDocFormat ;
oRpt.Export();
Response.ClearContent();
Response.ClearHeaders();
Response.AppendHeader("Content-Disposition","inline;filename=" + Server.UrlEncode(Path.GetFileName(Fname)));
Response.ContentType = "application/pdf";
Response.WriteFile(Fname);
Response.Flush();
Response.Close();
System.IO.File.Delete(Fname);