关于水晶报表的(贴点自己看)

License : AV860-01CS00G-U7000NC
SN : 1231467890

 

.net自带的注册

水晶报表注册码
注册号:6707437608
密码:AAP5GKS0000GDE100DS

用法1

 1 ReportDoc   =   new   ReportDocument();
 2             ReportDoc.Load(Server.MapPath( " myReport.rpt " ));
 3              #region 解决登录错误问题
 4            TableLogOnInfo  logonInfo  = new TableLogOnInfo();//
 5            foreach( CrystalDecisions.CrystalReports.Engine.Table tb in ReportDoc.Database.Tables)
 6            {
 7                logonInfo = tb.LogOnInfo;
 8                logonInfo.ConnectionInfo.ServerName = "(local)";
 9                logonInfo.ConnectionInfo.DatabaseName = "myDatabase";//
10                logonInfo.ConnectionInfo.UserID = "sa";
11                logonInfo.ConnectionInfo.Password = "111";//
12                tb.ApplyLogOnInfo(logonInfo);
13            
14            }

15            #endregion

16             CrystalReportViewer1.ReportSource  =  ReportDoc;;
2
1      string  strProvider  =   " Server=(local);DataBase=myDatabase;UID=sa;PWD=111 " ;
2             SqlConnection MyConn  =   new  SqlConnection(strProvider);
3             MyConn.Open();
4              string  strSel  =   " Select * from SaleOfCuntry " ;
5             SqlDataAdapter MyAdapter  =   new  SqlDataAdapter(strSel,MyConn);
6             DataSet1 ds  =   new  DataSet1();
7             MyAdapter.Fill(ds, " SaleOfCuntry " );
8             ReportDoc.SetDataSource(ds);
9             Crv.ReportSource  =  ReportDoc;
导出
 1     CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts  =   new          CrystalDecisions.Shared.DiskFileDestinationOptions();
 2             ReportDoc.ExportOptions.ExportDestinationType  =  CrystalDecisions.Shared.ExportDestinationType.DiskFile;
 3              switch  (ddlFormat.SelectedItem.Text)
 4              {
 5                case "Rich Text (RTF)":
 6                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.RichText;//
 7                         DiskOpts.DiskFileName = "c://Output.rtf";//
 8                    break;
 9                case "Portable Document (PDF)":
10                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;//
11                         DiskOpts.DiskFileName = "c://Output.pdf";//
12                    break;
13                case "MS Word (DOC)":
14                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.WordForWindows;//
15                         DiskOpts.DiskFileName = "c://Output.doc";//
16                    break;
17                case "MS Excel (XLS)":
18                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.Excel;//
19                         DiskOpts.DiskFileName = "c://Output.xls";//
20                    break;
21                default:
22                    break;
23            }

24             ReportDoc.ExportOptions.DestinationOptions  =  DiskOpts;
25              ReportDoc.Export();
打印
 1      string  strPrinterName; 
 2             strPrinterName  =   @" Canon Bubble-Jet BJC-210SP " ;
 3              //  设置打印页边距 
 4             PageMargins margins; 
 5             margins  =  ReportDoc.PrintOptions.PageMargins; 
 6             margins.bottomMargin  =   250
 7             margins.leftMargin  =   350
 8             margins.rightMargin  =   350
 9             margins.topMargin  =   450 ;     
10             ReportDoc.PrintOptions.ApplyPageMargins(margins);     
11              // 应用打印机名称 
12             ReportDoc.PrintOptions.PrinterName  =  strPrinterName;     
13              //  打印     //  打印报表。将 startPageN 和 endPageN 
14              //  参数设置为 0 表示打印所有页。
15             ReportDoc.PrintToPrinter( 1 false , 0 , 0 );     
window用法
1 OpenFileDialog dlg  =   new  OpenFileDialog();
2             dlg.Title  =   " 打开水晶报表文件 " ;
3             dlg.Filter  =   " 水晶报表文件(*.rpt)|*.rpt|所有文件|*.* " ;
4              if (dlg.ShowDialog() == DialogResult.OK)
5              {
6                crystalReportViewer1.ReportSource = dlg.FileName;
7            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值