91在线一级黄片|91视频在线观看18|成人夜间呦呦网站|91资源欧美日韩超碰|久久最新免费精品视频一区二区三区|国产探花视频在线观看|黄片真人免费三级片毛片|国产人无码视频在线|精品成人影视无码三区|久久视频爱久久免费精品

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
.NET水晶報表優(yōu)劣談

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

創(chuàng)新互聯(lián)建站專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于成都網(wǎng)站制作、成都網(wǎng)站設計、肅寧網(wǎng)絡推廣、成都小程序開發(fā)、肅寧網(wǎng)絡營銷、肅寧企業(yè)策劃、肅寧品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)建站為所有大學生創(chuàng)業(yè)者提供肅寧建站搭建服務,24小時服務熱線:18982081108,官方網(wǎng)址:www.cdcxhl.com

1、.NET水晶報表的好處

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

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

2、.NET水晶報表的兩種格式

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

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

3. .NET水晶報表使用的庫

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

2)水晶報表設計器(CRDesigner.dll),作用:設計標題,插入數(shù)據(jù)等

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

4)需要引入的命名空間

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

4、Pull模式下使用水晶報表

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

2)拖放CrystalReportViewer

3)綁定

5、讀取.NET水晶報表文件

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

6. B/S下讀取報表的文件

 
 
 
  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)錯誤(登錄的用戶名和密碼不對)

 
 
 
  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. 導出水晶報表的文件

 
 
 
  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下水晶報表的打印

 
 
 
  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ù)設置為0,表示打印所用頁  
  12.    } 

網(wǎng)頁名稱:.NET水晶報表優(yōu)劣談
轉載注明:http://m.jiaoqi3.com/article/dpjssco.html