blogjava's web log

          blogjava's web log
          ...

          水晶報(bào)表相關(guān)[導(dǎo)入]

          pull模式

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

          ????????}




          push模式

          打印

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



          導(dǎo)出


          ????????
          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();
          ????????}

          子報(bào)表
          myReport?ReportDoc?=?new?myReport();?
          ????????
          protected?void?Page_Load(object?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          //?在此處放置用戶代碼以初始化頁(yè)面
          ????????????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
          //改變報(bào)表文本
          ????????protected?void?btnChangeText_Click(object?sender,?System.EventArgs?e)
          ????????
          {
          ????????????TextObject?tb?
          =?(TextObject?)ReportDoc.ReportDefinition.ReportObjects["Text2"];
          ???????????
          ????????????tb.Text?
          =?"訂單號(hào)";
          ????????}

          //選擇一個(gè)報(bào)表查看

          protected?void?Page_Load(object?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          //?在此處放置用戶代碼以初始化頁(yè)面
          ????????????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);
          ?????????????
          //打印人傳給報(bào)表
          ????????????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 閱讀(481) 評(píng)論(0)  編輯  收藏 所屬分類: dot net相關(guān)

          導(dǎo)航

          常用鏈接

          留言簿(44)

          新聞檔案

          2.動(dòng)態(tài)語(yǔ)言

          3.工具箱

          9.文檔教程

          友情鏈接

          搜索

          最新評(píng)論

          主站蜘蛛池模板: 隆尧县| 昌平区| 凤山市| 手游| 分宜县| 阿克苏市| 乌拉特中旗| 孟村| 太仆寺旗| 安平县| 基隆市| 新津县| 咸丰县| 玉山县| 都兰县| 自贡市| 曲沃县| 仪陇县| 永年县| 沅陵县| 桂东县| 融水| 高密市| 武山县| 凤城市| 荆州市| 湄潭县| 于田县| 两当县| 新竹县| 襄汾县| 灯塔市| 湖州市| 东至县| 舟曲县| 新津县| 常宁市| 衡阳市| 宝山区| 侯马市| 凭祥市|