blogjava's web log

          blogjava's web log
          ...

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

          pull模式

          ???????? protected ? void ?Page_Load( object ?sender,?System.EventArgs?e)
          ????????
          {
          ????????????
          // ?在此處放置用戶代碼以初始化頁面
          ????????????ReportDoc?? = ? new ??ReportDocument();
          ????????????ReportDoc.Load(Server.MapPath(
          " myReport.rpt " ));
          ????????????
          解決登錄錯(cuò)誤問題
          ????????????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è)置打印頁邊距?
          ????????????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?表示打印所有頁。
          ????????????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)
          ????????
          {
          ????????????
          //?在此處放置用戶代碼以初始化頁面
          ????????????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?
          =?"訂單號";
          ????????}

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

          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);
          ?????????????
          //打印人傳給報(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 閱讀(484) 評論(0)  編輯  收藏 所屬分類: dot net相關(guān)

          導(dǎo)航

          常用鏈接

          留言簿(44)

          新聞檔案

          2.動態(tài)語言

          3.工具箱

          9.文檔教程

          友情鏈接

          搜索

          最新評論

          主站蜘蛛池模板: 南昌市| 罗源县| 天等县| 米易县| 黔江区| 山东省| 兴安县| 上高县| 西畴县| 新竹市| 东至县| 兴宁市| 陆良县| 顺义区| 新巴尔虎右旗| 福海县| 宾川县| 冷水江市| 盐津县| 陇川县| 屯昌县| 南京市| 晋中市| 治多县| 揭东县| 梅河口市| 新巴尔虎右旗| 台中县| 广宁县| 乐亭县| 凌云县| 柳林县| 大理市| 赤峰市| 湘乡市| 大方县| 乌拉特后旗| 上思县| 浦县| 安多县| 息烽县|