自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

.NET水晶報(bào)表優(yōu)劣談

開發(fā) 后端
這里將介紹.NET水晶報(bào)表優(yōu)劣,通過介紹水晶報(bào)表的好處及相關(guān)功能介紹,希望能對(duì)大家了解.NET水晶報(bào)表有所幫助。

.NET水晶報(bào)表首先要從概念入手,水晶報(bào)表(Crystal Report)是業(yè)內(nèi)最專業(yè)、功能最強(qiáng)的報(bào)表系統(tǒng),它除了強(qiáng)大的報(bào)表功能外,最大的優(yōu)勢是實(shí)現(xiàn)了與絕大多數(shù)流行開發(fā)工具的集成和接口。

1、.NET水晶報(bào)表的好處

1)利用水晶報(bào)表可以進(jìn)行數(shù)值求平均值,畫圖等

2)利用水晶報(bào)表可以把文件導(dǎo)出不同的格式(word等)

2、.NET水晶報(bào)表的兩種格式

1)pull模式,不利用DataSet,直接從數(shù)據(jù)庫中取出數(shù)據(jù)

2) push模式,使用DataSet,利用它進(jìn)行數(shù)據(jù)的加載和處理等

3. .NET水晶報(bào)表使用的庫

1)水晶報(bào)表的引擎(CREnging.dll),作用:合并數(shù)據(jù),裝換格式

2)水晶報(bào)表設(shè)計(jì)器(CRDesigner.dll),作用:設(shè)計(jì)標(biāo)題,插入數(shù)據(jù)等

3)水晶報(bào)表查看控件(CRWebFormViewer.DLL)

4)需要引入的命名空間

  1. using CrystalDecisions.CrystalReports.Engine;   
  2. using CrystalDecisions.Shared;  

4、Pull模式下使用水晶報(bào)表

1)創(chuàng)建rpt文件

2)拖放CrystalReportViewer

3)綁定

5、讀取.NET水晶報(bào)表文件

  1. private void ReadCRV(cryatalReportViewer crv)  
  2.    {  
  3.      openFileDialog dlg=new OpenFileDialog();  
  4.      dlg.Title="打開水晶報(bào)表文件";  
  5.      dlg.Filter="水晶報(bào)表文件(*.rpt)|*.rpt|所有文件|*.*";  
  6.      if(dlg.showDialog()==DialogResult.OK)  
  7.      {  
  8.        crv.ReportSource=dlg.FileName;  
  9.      }  
  10.    } 

6. B/S下讀取報(bào)表的文件

  1. private void ReadCRV(cryatalReportViewer crv,File file)  
  2.    {  
  3.      string strName=file.PostedFile.FileName;  
  4.      if(strName.Trim()!="")  
  5.      {  
  6.        crv.ReportSource=strName 
  7.        Session["fileName"]=strName;  
  8.      }  
  9.    } 

在B/S中要防止數(shù)據(jù)源的丟失

  1. priavte void Page_Load(object sender,System.EventArgs e)  
  2.     {  
  3.       if(Session["fileName"]!=null)  
  4.       {  
  5.         crv.ReportSource=Session["fileName"].ToString();  
  6.       }  
  7.     } 

7. 假如直接從數(shù)據(jù)庫中讀取數(shù)據(jù)

采用PULL模式可能出現(xiàn)錯(cuò)誤(登錄的用戶名和密碼不對(duì))

  1. private void ReadCRV(CrystalReportViewer crv,CrystalReport cr)  
  2.    {  
  3.       ReportDocument reportDoc=new ReportDocument();  
  4.       reportDoc.Load(Server.MapPath(cr));//要加載的rpt文件的名字  
  5.       //解決登錄的問題  
  6.       TableLogOnInfo logonInfo = new TableLogOnInfo();  
  7.       foreach(Table tb in ReportDoc.Database.Tables)  
  8.       {  
  9.         logonInfo=tb.LogOnInfo;  
  10.         logonInfo.ConnectionInfo.ServerName="(loacl)";  
  11.         logonInfo.ConnectionInfo.DatabaseName="Pubs";  
  12.         logonInfo.ConnectionInfo.UserId="sa";  
  13.         logonInfo.ConnectionInfo.Password="";  
  14.         tb.ApplyLogOnInfo(logonInfo);  
  15.       }  
  16.       crv.ReportSource=reportDoc;  
  17.    } 

8. 采用Push模式,直接在數(shù)據(jù)源讀取

  1. private void BindReport(CrystalReportViewer crv)  
  2.   {  
  3.     string strProvider="Server=(local);DataBase=pubs;uid=sa;pwd=";  
  4.     CrystalReport cr=new CrystalReport();  
  5.     DataSet ds=new DataSet();  
  6.     SqlConnection conn=new SqlConnection(strProvider);  
  7.     conn.open();  
  8.     string strSql="select * from jobs";  
  9.     SqlDataAdapter dap=new SqlDataAdapter(strSql,conn);  
  10.     adp.Fill(ds,"jobs");  
  11.     cr.SetDataSource(ds);  
  12.     crcrv.ReportSource=cr;  
  13.   } 

9. 導(dǎo)出水晶報(bào)表的文件

  1. private void ExportCrv(CrystalReport cr)  
  2.    {  
  3.       DiskFileDestionOptions dOpt=new DiskFileDestionOptions();  
  4.       cr.ExportOptions.ExportDestinationType=ExportDestinationType.DiskFile();  
  5.       cr.ExportOptions.ExportFormatType= ExportFormatType.PortableDocFormat;  
  6.       dOpt.DiskFileName="C:\output.pdf";  
  7.       cr.ExportOptions.DestinationOptions=dOpt;  
  8.       cr.Export();  
  9.         
  10.    }  
  11.    private void ExportCrv(CrystalReport cr,string strType,string strPath)  
  12.    {  
  13.       DiskFileDestionOptions dOpt=new DiskFileDestionOptions();  
  14.       cr.ExportOptions.ExportDestinationType=ExportDestinationType.DiskFile();  
  15.       switch(strType)  
  16.       {  
  17.          case "RTF":  
  18.            cr.ExportOptions.ExportFormatType=ExportFormatType.RichText;  
  19.            dOpt.DiskFileName=strPath;  
  20.            break;  
  21.          case "PDF":  
  22.            cr.ExportOptions.ExportFormatType=ExportFormatType.PortableDocFormat;  
  23.            dOpt.DiskFileName=strPath;  
  24.            break;  
  25.          case "DOC":  
  26.            cr.ExportOptions.ExportFormatType=ExportFormatType.WordForWindows;  
  27.            dOpt.DiskFileName=strPath;  
  28.            break;  
  29.          case "XLS":  
  30.            cr.ExportOptions.ExportFormatType=ExportFormatType.Excel;  
  31.            dOpt.DiskFileName=strPath;  
  32.            break;  
  33.          default;  
  34.          break;  
  35.              
  36.       }  
  37.       cr.ExportOptions.DestinationOptions=dOpt;  
  38.       cr.Export();  
  39.  
  40.    } 

10 B/S下水晶報(bào)表的打印

  1. priavte void PrintCRV(CrystalReport cr)  
  2.    {  
  3.      string strPrinterName=@"printName";  
  4.      PageMargins margins=cr.PrintOptions.PageMargins;  
  5.      margins.bottomMargin = 250;  
  6.      margins.leftMargin = 350;  
  7.      margins.rightMargin = 350;  
  8.      margins.topMargin = 450;  
  9.      cr.PrintOptions.ApplyPageMargins(margins);  
  10.      cr.PrintOptions.printerName=strPrinterName;  
  11.      cr.PrintToPrinter(1,false,0,0)//參數(shù)設(shè)置為0,表示打印所用頁  
  12.    } 

【編輯推薦】

  1. 深入淺出.NET接口:阿貓阿狗和程序員
  2. 程序員如何選擇入門編程語言?
  3. 程序員最常犯的五大非技術(shù)性錯(cuò)誤
  4. Java程序員的知識(shí)架構(gòu)淺析
  5. 專家級(jí)程序員的“飼養(yǎng)”心得
責(zé)任編輯:彭凡 來源: 博客園
相關(guān)推薦

2009-07-29 09:29:06

ASP.NET水晶報(bào)表

2009-08-02 11:48:58

ASP.NET水晶報(bào)表ASP.NET

2009-07-30 13:57:39

ASP.NET水晶報(bào)表ASP.NET

2010-01-14 10:52:13

VB.NET水晶報(bào)表

2009-10-16 13:30:51

VB.NET水晶報(bào)表控

2009-11-05 14:03:28

Visual Stud

2009-12-15 17:20:07

VS 水晶報(bào)表

2009-08-31 16:09:42

.net水晶報(bào)表使用學(xué)

2009-08-25 17:00:32

ASP.NET水晶報(bào)表

2009-08-31 15:11:23

C#調(diào)用水晶報(bào)表

2009-08-31 16:01:28

C#水晶報(bào)表數(shù)據(jù)獲取方

2009-08-31 15:54:35

2009-12-01 13:50:19

VS2003水晶報(bào)表

2009-11-26 13:27:10

VS2003水晶報(bào)表

2009-11-26 13:40:53

2009-11-27 10:14:44

2009-02-10 11:19:54

2017-01-13 15:24:58

助力 制造

2017-09-27 18:21:36

報(bào)表性能集算器

2013-02-21 10:13:36

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)