zoukankan      html  css  js  c++  java
  • Devexpress EXCEL导出

          #region EXCEL导出
    
            /// <summary>
            /// EXCEL导出
    /// </summary> /// <param name="saveFileName">文件名称</param> /// <param name="gridView">待导出的gridView数据</param> public void ExportToExcel(string saveFileName, DevExpress.XtraGrid.Views.Base.BaseView gridView) { try { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.DefaultExt = "xls"; saveDialog.Filter = "导出Excel(*.xls)|*.xls"; saveDialog.FileName = saveFileName + DateTime.Now.ToString("yyyyMMddHHmmss"); if (saveDialog.ShowDialog() != DialogResult.OK) return; saveFileName = saveDialog.FileName; Cursor.Current = Cursors.WaitCursor; DevExpress.XtraExport.IExportXlsProvider provider = new DevExpress.XtraExport.ExportXlsProvider(saveFileName); this.FindForm().Refresh(); DevExpress.XtraGrid.Export.BaseExportLink link = gridView.CreateExportLink(provider); link.ExportAll = true; link.Progress += new DevExpress.XtraGrid.Export.ProgressEventHandler(Export_Progress);//进度条事件 link.ExportTo(true); provider.Dispose(); link.Progress -= new DevExpress.XtraGrid.Export.ProgressEventHandler(Export_Progress); Cursor.Current = Cursors.Default; MessageUtil.ShowTips("导出成功!"); } catch (Exception ex) {
             MessageUtil.ShowError("导出失败!"); } } /// <summary> /// 进度条事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Export_Progress(object sender, DevExpress.XtraGrid.Export.ProgressEventArgs e) { if (e.Phase == DevExpress.XtraGrid.Export.ExportPhase.Link) { // progressBarControl1.Position = e.Position; this.Update(); } } #endregion
  • 相关阅读:
    Redis学习笔记-安装篇(Centos7)
    图片上传预览方式,了解下?
    Angular中依赖注入方式的几种写法
    Javascript实现打开或退出浏览器全屏
    从头开始学Web开发—CSS_01
    JavaScript DOM知识 (一)
    javascript中的scroll事件
    javascript中继承的实现
    认识Javascript中的作用域和作用域链
    javascript中的闭包
  • 原文地址:https://www.cnblogs.com/xuzai/p/4723340.html
Copyright © 2011-2022 走看看