关键代码:
#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
新闻热点
疑难解答