关键代码:
#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>publicstaticvoidToXls(thisGridControl grid,stringfileName)
{
SaveFileDialog _saveFileDialog =newSaveFileDialog();
_saveFileDialog.Title ="导出Excel";
_saveFileDialog.Filter ="Excel文件(*.xls)|*.xls";
_saveFileDialog.FileName = fileName;
DialogResult _dialogResult = _saveFileDialog.ShowDialog();if(_dialogResult == DialogResult.OK)
{
XlsExportOptions _options =newXlsExportOptions();
_options.SupPRess256ColumnsWarning =true;
_options.Suppress65536RowsWarning =true;
_options.TextExportMode = TextExportMode.Text;
grid.ExportToXls(_saveFileDialog.FileName);
DevMessageBoxHelper.ShowInfo("导出到Excel成功!");
}
}#endregion
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp{ background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }