C # DevExpress Gridcontrol export table "Go"

Source: Internet
Author: User

DevExpress Gridcontrol provides convenient data export function, can easily export exce,pdf,html page, world form, no need to write extra code, convenient and fast.

///<summary>Export table///</summary>///<param name= "GridControl1" ></param>PublicStaticvoidDevexpressgridcontrolexport (Gridcontrol gridControl1) {using (var savedialog =New SaveFileDialog ()) {savedialog.filter = resources.commonfunction_devexpressgridcontrolexport_excel_97_2007 file ___ Xls_excel_2010___xlsx_excel__2003___xls____xls_excel__2010____xlsx____xlsx__richtext_file___rtf____rtf__pdf_ file___pdf____pdf__html_file___html____html;if (savedialog.showdialog () = = DialogResult.Cancel)Returnvar exportfilepath = Savedialog.filename;var fileextenstion =New FileInfo (Exportfilepath). Extension;Switch (fileextenstion) {Case". xls": Gridcontrol1.exporttoxls (Exportfilepath);BreakCase". xlsx": gridcontrol1.exporttoxlsx (Exportfilepath);BreakCase". rtf": Gridcontrol1.exporttortf (Exportfilepath);BreakCase". pdf": Gridcontrol1.exporttopdf (Exportfilepath);BreakCase". html": gridcontrol1.exporttohtml (Exportfilepath);BreakCase". mht": gridcontrol1.exporttomht (Exportfilepath);Break }if (file.exists (Exportfilepath)) {try {if (Dialogresult.yes = = MessageBox.Show (Resources.commonfunction_devexpressgridcontrolexport_, Resources.commonfunction_devexpressgridcontrolexport_ hint, messageboxbuttons.yesno) {Process.Start (ExportFilePath ); } }catch { var msg = "The file could not being opened." + Environment.NewLine + Environment.NewLine + "Path:" + Exportfilepath; MessageBox.Show (msg, resources.commonfunction_devexpressgridcontrolexport_error_, MessageBoxButtons.OK, MESSAGEBOXICON.ERROR); }} else { var msg = "The file could not being saved." + Environment.NewLine + Environment.NewLine + "Path:" + Exportfilepath; MessageBox.Show (msg, resources.commonfunction_devexpressgridcontrolexport_error_, MessageBoxButtons.OK, MESSAGEBOXICON.ERROR); } } }
Original website: 70212796

C # DevExpress Gridcontrol export table "Go"

Related Article

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.