blogjava's web log

          blogjava's web log
          ...

          水晶報表相關[導入]

          pull模式

          ???????? protected ? void ?Page_Load( object ?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          // ?在此處放置用戶代碼以初始化頁面
          ????????????ReportDoc?? = ? new ??ReportDocument();
          ????????????ReportDoc.Load(Server.MapPath(
          " myReport.rpt " ));
          ????????????
          解決登錄錯誤問題
          ????????????CrystalReportViewer1.ReportSource?
          = ?ReportDoc;;

          ????????}




          push模式

          打印

          protected ? void ?btnPrint_Click( object ?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          // ?指定打印機名稱,這里是網絡工作站Gigi上的打印機Hp?Jet?6?????
          ???????????? string ?strPrinterName;?
          ????????????strPrinterName?
          = ? @" Canon?Bubble-Jet?BJC-210SP " ;
          ????????????
          // ?設置打印頁邊距?
          ????????????PageMargins?margins;?
          ????????????margins?
          = ?ReportDoc.PrintOptions.PageMargins;?
          ????????????margins.bottomMargin?
          = ? 250 ;?
          ????????????margins.leftMargin?
          = ? 350 ;?
          ????????????margins.rightMargin?
          = ? 350 ;?
          ????????????margins.topMargin?
          = ? 450 ;?????
          ????????????ReportDoc.PrintOptions.ApplyPageMargins(margins);?????
          ????????????
          // 應用打印機名稱?
          ????????????ReportDoc.PrintOptions.PrinterName? = ?strPrinterName;?????
          ????????????
          // ?打印???? // ?打印報表。將?startPageN?和?endPageN?
          ????????????
          // ?參數設置為?0?表示打印所有頁。
          ????????????ReportDoc.PrintToPrinter( 1 ,? false , 0 , 0 );?????
          ????????
          ????????}



          導出


          ????????
          protected ? void ?btnExport_Click( object ?sender,?System.EventArgs?e)
          ????????
          {
          ????????????CrystalDecisions.Shared.DiskFileDestinationOptions?DiskOpts?
          = ? new ?????????CrystalDecisions.Shared.DiskFileDestinationOptions();
          ????????????ReportDoc.ExportOptions.ExportDestinationType?
          = ?CrystalDecisions.Shared.ExportDestinationType.DiskFile;
          ????????????
          switch ?(ddlFormat.SelectedItem.Text)
          ????????????
          {
          ????????????????
          case ? " Rich?Text?(RTF) " :
           ????????????????????????ReportDoc.ExportOptions.ExportFormatType?
          = ???CrystalDecisions.Shared.ExportFormatType.RichText; //
           ????????????????????????DiskOpts.DiskFileName? = ? " c:\\Output.rtf " ; //
          ???????????????????? break ;
          ????????????????
          case ? " Portable?Document?(PDF) " :
           ????????????????????????ReportDoc.ExportOptions.ExportFormatType?
          = ???CrystalDecisions.Shared.ExportFormatType.PortableDocFormat; //
           ????????????????????????DiskOpts.DiskFileName? = ? " c:\\Output.pdf " ; //
          ???????????????????? break ;
          ????????????????
          case ? " MS?Word?(DOC) " :
           ????????????????????????ReportDoc.ExportOptions.ExportFormatType?
          = ???CrystalDecisions.Shared.ExportFormatType.WordForWindows; //
           ????????????????????????DiskOpts.DiskFileName? = ? " c:\\Output.doc " ; //
          ???????????????????? break ;
          ????????????????
          case ? " MS?Excel?(XLS) " :
           ????????????????????????ReportDoc.ExportOptions.ExportFormatType?
          = ???CrystalDecisions.Shared.ExportFormatType.Excel; //
           ????????????????????????DiskOpts.DiskFileName? = ? " c:\\Output.xls " ; //
          ???????????????????? break ;
          ????????????????
          default :
          ????????????????????
          break ;
          ????????????}

          ????????????ReportDoc.ExportOptions.DestinationOptions?
          = ?DiskOpts;
           ????????????ReportDoc.Export();
          ????????}

          子報表
          myReport?ReportDoc?=?new?myReport();?
          ????????
          protected?void?Page_Load(object?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          //?在此處放置用戶代碼以初始化頁面
          ????????????string?strProvider?=?"Server=(local);DataBase=Northwind;UID=sa;PWD=111";
          ????????????SqlConnection?MyConn?
          =?new?SqlConnection(strProvider);
          ????????????MyConn.Open();
          ????????????
          string?strSelOrders?=?"Select?*?from?orders";
          ????????????
          string?strSelOrdersDetails?=?"Select?*?from?[Order?Details]";
          ????????????SqlDataAdapter?daOrder?
          =?new?SqlDataAdapter(strSelOrders,MyConn);
          ????????????SqlDataAdapter?daOrderDetails?
          =?new?SqlDataAdapter(strSelOrdersDetails,MyConn);
          ????????????DataSet?ds?
          =?new?DataSet();
          ????????????daOrder.Fill(ds,
          "orders");
          ????????????daOrderDetails.Fill(ds,
          "Order?Details");
          ????????????
          ????????????ReportDoc.SetDataSource(ds);
          ????????????cRV.ReportSource?
          =?ReportDoc;
          ????????}


          ????????
          Web?Form?Designer?generated?code
          //改變報表文本
          ????????protected?void?btnChangeText_Click(object?sender,?System.EventArgs?e)
          ????????
          {
          ????????????TextObject?tb?
          =?(TextObject?)ReportDoc.ReportDefinition.ReportObjects["Text2"];
          ???????????
          ????????????tb.Text?
          =?"訂單號";
          ????????}

          //選擇一個報表查看

          protected?void?Page_Load(object?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          //?在此處放置用戶代碼以初始化頁面
          ????????????if(Session["filename"]!=null)
          ????????????????CrystalReportViewer1.ReportSource?
          =?Session["filename"].ToString();

          ????????}

          protected?void?btnLoad_Click(object?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          string?strName?=?File1.PostedFile.FileName;
          ????????????
          if(strName.Trim()!="")
          ????????????
          {
          ????????????????CrystalReportViewer1.ReportSource?
          =?strName;
          ????????????????Session[
          "filename"]?=?strName;
          ????????????}


          ????????}

          ?

          winform? 使用

          ????//customers1是ReportDocument控件
          ????????????PrintForm?printForm?=?new?PrintForm();
          ????????????
          this.customers1.Load();
          ????????????
          this.customers1.SetDataSource(this.myDataSet);
          ?????????????
          //打印人傳給報表
          ????????????this.customers1.SetParameterValue("printczy",this.tbPrintCzy.Text);
          ????????????
          this.customers1.Section1.ReportObjects["testField"].Name="city";
          ????????????printForm.crystalReportViewer1.ReportSource?
          =?this.customers1;
          ????????????printForm.WindowState?
          =?FormWindowState.Maximized;
          ????????????printForm.ShowDialog();

          posted on 2006-05-28 14:12 record java and net 閱讀(484) 評論(0)  編輯  收藏 所屬分類: dot net相關

          導航

          常用鏈接

          留言簿(44)

          新聞檔案

          2.動態語言

          3.工具箱

          9.文檔教程

          友情鏈接

          搜索

          最新評論

          主站蜘蛛池模板: 临湘市| 弥渡县| 左权县| 犍为县| 雷州市| 成安县| 普宁市| 沙河市| 仪征市| 栖霞市| 永新县| 怀安县| 锦州市| 方山县| 阜平县| 五台县| 昌黎县| 崇文区| 教育| 玛多县| 阿图什市| 班玛县| 双牌县| 高密市| 柏乡县| 东兴市| 阿尔山市| 本溪市| 宜君县| 普陀区| 饶阳县| 博爱县| 河东区| 将乐县| 翁源县| 昂仁县| 伊宁市| 桦川县| 屏南县| 安庆市| 齐齐哈尔市|