导出CrystalReport的文件硬编码的格式
1![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new CrystalDecisions.Shared.DiskFileDestinationOptions();//提供属性,以便获取和设置导出到磁盘时的文件名
3
ReportDoc.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;//指定导出目标类型
4
switch (ddlFormat.SelectedItem.Text)
5
{
6
case "Rich Text (RTF)":
7
ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.RichText;//获取或设置导出格式类型。
8
DiskOpts.DiskFileName = "c:\\Output.rtf";//
9
break;
10
case "Portable Document (PDF)":
11
ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;//获取或设置导出格式类型。
12
DiskOpts.DiskFileName = "c:\\Output.pdf";//
13
break;
14
case "MS Word (DOC)":
15
ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.WordForWindows;//获取或设置导出格式类型。
16
DiskOpts.DiskFileName = "c:\\Output.doc";//
17
break;
18
case "MS Excel (XLS)":
19
ReportDoc.ExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel;//获取或设置导出格式类型。
20
DiskOpts.DiskFileName = "c:\\Output.xls";//
21
break;
22
default:
23
break;
24
}
25
ReportDoc.ExportOptions.DestinationOptions = DiskOpts;//导出过程中访问格式选项的首选方式
26
ReportDoc.Export();//道出报表方法rt()
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2。打映的硬编码方式
1
// 指定打印机名称,这里是网络工作站Gigi上的打印机Hp Jet 6
2
string strPrinterName;
3
strPrinterName = @"Canon Bubble-Jet BJC-210SP";
4
// 设置打印页边距
5
PageMargins margins;
6
margins = ReportDoc.PrintOptions.PageMargins;
7
margins.bottomMargin = 250;
8
margins.leftMargin = 350;
9
margins.rightMargin = 350;
10
margins.topMargin = 450;
11
ReportDoc.PrintOptions.ApplyPageMargins(margins);
12
//应用打印机名称
13
ReportDoc.PrintOptions.PrinterName = strPrinterName;
14
// 打印 // 打印报表。将 startPageN 和 endPageN
15
// 参数设置为 0 表示打印所有页。
16
ReportDoc.PrintToPrinter(1, false,0,0);
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3.完整的代码留下足迹,发给抛下砖头的人,呵呵