DevExpress GirdControl 导出EXCEL 表头样式怎么设置
展开全部
/// <summary>
/// 导出到Excel
/// </summary>
/// <param name="gridControl">GridControl</param>
/// <param name="fileNameTitle">导出到Excel的Sheet文件名称</param>
public static void ExportToExcel(this GridControl gridControl, string fileNameTitle)
{
var fileName = SaveAs(fileNameTitle);
XlsExportOptions options = new XlsExportOptions();
options.Suppress256ColumnsWarning = true;
options.Suppress65536RowsWarning = true;
options.TextExportMode = TextExportMode.Text;
options.SheetName = fileNameTitle;
var gridView = (GridView)gridControl.Views[0];
gridView.AppearancePrint.Row.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
gridView.OptionsPrint.AutoWidth = false;
gridView.AppearancePrint.Row.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
gridControl.ExportToXls(fileName, options);
if (MessageCommon.ShowQueInf("保存成功,是否打开文件?") == DialogResult.Yes)
System.Diagnostics.Process.Start(fileName);//打开指定路径下的文件
}
/// 导出到Excel
/// </summary>
/// <param name="gridControl">GridControl</param>
/// <param name="fileNameTitle">导出到Excel的Sheet文件名称</param>
public static void ExportToExcel(this GridControl gridControl, string fileNameTitle)
{
var fileName = SaveAs(fileNameTitle);
XlsExportOptions options = new XlsExportOptions();
options.Suppress256ColumnsWarning = true;
options.Suppress65536RowsWarning = true;
options.TextExportMode = TextExportMode.Text;
options.SheetName = fileNameTitle;
var gridView = (GridView)gridControl.Views[0];
gridView.AppearancePrint.Row.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
gridView.OptionsPrint.AutoWidth = false;
gridView.AppearancePrint.Row.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
gridControl.ExportToXls(fileName, options);
if (MessageCommon.ShowQueInf("保存成功,是否打开文件?") == DialogResult.Yes)
System.Diagnostics.Process.Start(fileName);//打开指定路径下的文件
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询