(1)            ReportDocument rd = new ReportDocument();            rd.Load(Server.MapPath("AllAppraisalForm.rpt")); 
(2)           DataSet ds = new DataSet();           ds = GetTempDS(); //獲取DataSet在獲取DataSet值時,可以藉助資料集(*.xsd)               ds1.ReadXmlSchema(Server.MapPath("App_Code\\AllData.xsd"));資料集較臨時DataTable優點:省卻初時化(指定類型等)的麻煩.              如果RPT文件中沒有用到數據庫,則跳過本步驟.
(3)  try{                        rd.SetDataSource(ds.Tables[0]);                        DiskFileDestinationOptions diskOption = new DiskFileDestinationOptions();                       rd.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;                        rd.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;                        string FileName = fun.GetBadge() + "_" + this.lblBadge.Text.Trim();                        diskOption.DiskFileName = Server.MapPath("Report\\" + FileName + ".pdf");                        rd.ExportOptions.DestinationOptions = diskOption;                         rd.Export();}catch{}                finally{                        rd.Close(); //不能缺少,否則在服務器C:\Windows\Temp下產生的臨時文件不會被釋放掉.                        rd.Dispose();}
             (請不要忘記使用try { } catch { }finally { })注意:(1)如果RPT中用到兩張/多張表,則rd.SetDataSource()參數為DataSet如果只用到單張表,則rd.SetDataSource()必須指定到具體表ds.Tables[0] (2)為RPT文件中的"公式欄位"指定值,不可用常量(但是""和"  "除外)型如:rd.DataDefinition.FormulaFields["period"].Text = "'" + dtC.Rows[0]["datefrom"].ToString().Trim() + " 至 " + dtC.Rows[0]["dateto"].ToString().Trim() + "'"; 技巧:如果將輸出為對號,需要將該字段復值"P",然後在輸出時將相應字段的Font設置為:"Wingdings 2"即可.