License : AV860-01CS00G-U7000NC
SN : 1231467890
.net自带的注册
水晶报表注册码
注册号:6707437608
密码:AAP5GKS0000GDE100DS
用法1
1
ReportDoc = new ReportDocument();
2
ReportDoc.Load(Server.MapPath("myReport.rpt"));
3
解决登录错误问题
16
CrystalReportViewer1.ReportSource = ReportDoc;;
2

2

3

16

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;
导出

2

3

4

5

6

7

8

9

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();
打印

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

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用法

2

3

4

5

6

7

8

9

10

11

12

13

14

15

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
}

2

3

4

5

6

7
