标签:class books 文件名 dialog ext filename 字段 file log
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); }
标签:class books 文件名 dialog ext filename 字段 file log
原文地址:https://www.cnblogs.com/w2011/p/10276544.html