首页 > 学院 > 开发设计 > 正文

[DevExpress]导出到Excel

2019-11-14 16:17:01
字体:
来源:转载
供稿:网友

关键代码:

        #region 导出到Excel        /// <summary>        /// 导出到Excel        /// <para>eg:GridHelper.ToXls(gcLamp,string.Format("{0}_单灯电参数数据.xls", DateTime.Now.ToString("yyyyMMdd")));</para>        /// </summary>        /// <param name="grid">GridControl</param>        /// <param name="fileName">导出到Excel文件名称</param>        public static void ToXls(this GridControl grid, string fileName)        {            SaveFileDialog _saveFileDialog = new SaveFileDialog();            _saveFileDialog.Title = "导出Excel";            _saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";            _saveFileDialog.FileName = fileName;            DialogResult _dialogResult = _saveFileDialog.ShowDialog();            if (_dialogResult == DialogResult.OK)            {                XlsExportOptions _options = new XlsExportOptions();                _options.SupPRess256ColumnsWarning = true;                _options.Suppress65536RowsWarning = true;                _options.TextExportMode = TextExportMode.Text;                grid.ExportToXls(_saveFileDialog.FileName);                DevMessageBoxHelper.ShowInfo("导出到Excel成功!");            }        }        #endregion 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表