[DevExpress]导出到Excel_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > [DevExpress]导出到Excel

[DevExpress]导出到Excel

 2014/12/24 19:14:12  楚人游子  程序员俱乐部  我要评论(0)
  • 摘要:关键代码:#region导出到Excel///<summary>///导出到Excel///<para>eg:GridHelper.ToXls(gcLamp,string.Format("{0}_单灯电参数数据.xls",DateTime.Now.ToString("yyyyMMdd")));</para>///</summary>///<paramname="grid">
  • 标签:excel

关键代码:

class="csharpcode">        #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 
发表评论
用户名: 匿名