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.