码迷,mamicode.com
首页 > 其他好文 > 详细

[DevExpress]导出到Excel

时间:2014-12-24 17:49:49      阅读:300      评论:0      收藏:0      [点我收藏+]

标签:

关键代码:

        #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 

[DevExpress]导出到Excel

标签:

原文地址:http://www.cnblogs.com/Yan-Zhiwei/p/4182746.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!