首页 > 其他 > 详细

Syncfusion SfDataGrid 导出Excel

时间:2019-01-16 13:46:21      阅读:218      评论:0      收藏:0      [点我收藏+]
var options = new ExcelExportingOptions
            {
                ExcelVersion = ExcelVersion.Excel2013,
            };
//不需要导出的字段 options.ExcludeColumns.Add(
"InspectionRecordId"); options.ExcludeColumns.Add("PartName"); options.ExportUnBoundRows = false; var excelEngine = dataGrid.ExportToExcel(dataGrid.View, options); //.ExportToExcel(dataGrid.View, options); var workBook = excelEngine.Excel.Workbooks[0]; Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.Filter = "Excel Office 2013|*.xlsx"; //设置默认文件名(可以不设置) saveFileDialog.FileName = $"巡检记录({DateTime.Now:yy-MM-dd})"; saveFileDialog.DefaultExt = "xlsx"; saveFileDialog.AddExtension = true; //保存对话框是否记忆上次打开的目录 bool? result = saveFileDialog.ShowDialog(); //点了保存按钮进入 if (result == true) { workBook.SaveAs(saveFileDialog.FileName); }

 

Syncfusion SfDataGrid 导出Excel

原文:https://www.cnblogs.com/w2011/p/10276544.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!