Original article: Setting the format of the exported file in the Crystal Report
The export and print functions provided by the crystal report are very convenient to use, but sometimes the files to be exported do not need so many types. I have summarized some friends' codes on the Internet, you can use the code to customize the exported file type.
First, you need to define an enumeration:
Public Enum allowedexportformat {// <summary> // PDF. /// </Summary> pdf = 1, /// <summary> // Excel (97-2003) /// </Summary> excel2003 = 2, /// <summary> /// word (97-2003) /// </Summary> word2003 = 4, /// <summary> /// RTF /// </Summary> RTF = 8, /// <summary> /// crystal report /// </Summary> crystalreport = 16, /// <summary> // Excel (97-2003) (data only) /// </Summary> excel2003dataonly = 32, // <summary> // word (97-2003) -editable /// </Summary> word2003editable = 64, /// <summary> /// XML /// </Summary> xml = 128, /// <summary> // Excel (data only) // </Summary> exceldataonly = 512, /// <summary> /// CSV /// </Summary> CSV = 1024}
Then you can set the export format of the Crystal Report and select the corresponding enumerated value based on the export format you need.
crystalReportViewer1.AllowedExportFormats = (int)(AllowedExportFormat.Word2003 | AllowedExportFormat.PDF | AllowedExportFormat.XML);
As for the order of the default export format of the Crystal Report, I tested it casually and gave up if it didn't succeed.
Format settings of the exported file in the Crystal Report