Export the "push" method of crystalreport

Source: Internet
Author: User

Export the hard-coded format of the crystalreport File

 

1
2crystaldecisions. Shared. diskfiledestinationoptions diskopts = new crystaldecisions. Shared. diskfiledestinationoptions (); // provides attributes to obtain and set the file name when exporting data to a disk.
3 reportdoc. exportoptions. exportdestinationtype = crystaldecisions. Shared. exportdestinationtype. diskfile; // specify the export target type
4 switch (ddlformat. selecteditem. Text)
5 {
6 case "Rich Text (RTF )":
7 reportdoc. exportoptions. exportformattype = crystaldecisions. Shared. exportformattype. richtext; // obtain or set the export format type.
8 diskopts. diskfilename = "C: \ output. rtf ";//
9 break;
10 case "Portable Document (PDF )":
11 reportdoc. exportoptions. exportformattype = crystaldecisions. Shared. exportformattype. portabledocformat; // obtain or set the export format type.
12 diskopts. diskfilename = "C :\\ output.pdf ";//
13 break;
14 case "MS Word (DOC )":
15 reportdoc. exportoptions. exportformattype = crystaldecisions. Shared. exportformattype. wordforwindows; // obtain or set the export format type.
16 diskopts. diskfilename = "C: \ output.doc ";//
17 break;
18 case "MS Excel (xls )":
19 reportdoc. exportoptions. exportformattype = crystaldecisions. Shared. exportformattype. Excel; // obtain or set the export format type.
20 diskopts. diskfilename = "C: \ output.xls ";//
21 break;
22 default:
23 break;
24}
25 reportdoc. exportoptions. destinationoptions = diskopts; // the preferred method of ACCESS format options during the export process
26 reportdoc. Export (); // report method RT ()

2. Hard encoding method

 

1 // specify the printer name. Here is the HP jet 6 printer on the network workstation Gigi.
2 string strprintername;
3 strprintername = @ "Canon Bubble-jet BJC-210SP ";
4 // set the print margin
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 // application printer name
13 reportdoc. printoptions. printername = strprintername;
14 // print the report. Set startpagen and endpagen
15 // If the parameter is set to 0, all pages are printed.
16 reportdoc. printtoprinter (1, false, 0, 0 );

3. The complete code leaves a footprint and is sent to the person who leaves the bricks.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.