打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Devexpress GridControl.Export
private void mnuExportTable_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e){    using (SaveFileDialog saveDialog = new SaveFileDialog())    {        saveDialog.Filter = "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)        {            string exportFilePath = saveDialog.FileName;            string fileExtenstion = new FileInfo(exportFilePath).Extension;            switch (fileExtenstion)            {                case ".xls":                    gridControl.ExportToXls(exportFilePath);                    break;                case ".xlsx":                    gridControl.ExportToXlsx(exportFilePath);                    break;                case ".rtf":                    gridControl.ExportToRtf(exportFilePath);                    break;                case ".pdf":                    gridControl.ExportToPdf(exportFilePath);                    break;                case ".html":                    gridControl.ExportToHtml(exportFilePath);                    break;                case ".mht":                    gridControl.ExportToMht(exportFilePath);                    break;                default:                    break;            }            if (File.Exists(exportFilePath))            {               try               {                   //Try to open the file and let windows decide how to open it.                   System.Diagnostics.Process.Start(exportFilePath);                }                catch                {                    String msg = "The file could not be opened." + Environment.NewLine + Environment.NewLine + "Path: " + exportFilePath;                    MessageBox.Show(msg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);                }             }             else             {                 String msg = "The file could not be saved." + Environment.NewLine + Environment.NewLine + "Path: " + exportFilePath;                 MessageBox.Show(msg, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);             }        }    }}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Devexpress使用经验1
[WPF]Devexpress GridControl使用方法总汇
DevExpress控件GridControl中的列冻结详解
devpress
怎样让显示的记录换行?
C# winform DevExpress GridControl GridView大批量数据(20万条)导出Excel
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服