导出CrystalReport的文件硬编码的格式
 1
2 CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new         CrystalDecisions.Shared.DiskFileDestinationOptions();//提供属性,以便获取和设置导出到磁盘时的文件名
CrystalDecisions.Shared.DiskFileDestinationOptions DiskOpts = new         CrystalDecisions.Shared.DiskFileDestinationOptions();//提供属性,以便获取和设置导出到磁盘时的文件名
3 ReportDoc.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;//指定导出目标类型
            ReportDoc.ExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile;//指定导出目标类型
4 switch (ddlFormat.SelectedItem.Text)
            switch (ddlFormat.SelectedItem.Text)
5 {
            {
6 case "Rich Text (RTF)":
                case "Rich Text (RTF)":
7 ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.RichText;//获取或设置导出格式类型。
                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.RichText;//获取或设置导出格式类型。
8 DiskOpts.DiskFileName = "c:\\Output.rtf";//
                         DiskOpts.DiskFileName = "c:\\Output.rtf";//
9 break;
                    break;
10 case "Portable Document (PDF)":
                case "Portable Document (PDF)":
11 ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;//获取或设置导出格式类型。
                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;//获取或设置导出格式类型。
12 DiskOpts.DiskFileName = "c:\\Output.pdf";//
                         DiskOpts.DiskFileName = "c:\\Output.pdf";//
13 break;
                    break;
14 case "MS Word (DOC)":
                case "MS Word (DOC)":
15 ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.WordForWindows;//获取或设置导出格式类型。
                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.WordForWindows;//获取或设置导出格式类型。
16 DiskOpts.DiskFileName = "c:\\Output.doc";//
                         DiskOpts.DiskFileName = "c:\\Output.doc";//
17 break;
                    break;
18 case "MS Excel (XLS)":
                case "MS Excel (XLS)":
19 ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.Excel;//获取或设置导出格式类型。
                         ReportDoc.ExportOptions.ExportFormatType =   CrystalDecisions.Shared.ExportFormatType.Excel;//获取或设置导出格式类型。
20 DiskOpts.DiskFileName = "c:\\Output.xls";//
                         DiskOpts.DiskFileName = "c:\\Output.xls";//
21 break;
                    break;
22 default:
                default:
23 break;
                    break;
24 }
            }
25 ReportDoc.ExportOptions.DestinationOptions = DiskOpts;//导出过程中访问格式选项的首选方式
            ReportDoc.ExportOptions.DestinationOptions = DiskOpts;//导出过程中访问格式选项的首选方式
26 ReportDoc.Export();//道出报表方法rt()
             ReportDoc.Export();//道出报表方法rt()

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

 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号