using System; namespace HStation.WinFrmUI { public class ExcelSaveFilePathHelper { public static string SaveFilePathName(string fileName = null, string title = null, string filter = null) { string path = ""; System.Windows.Forms.SaveFileDialog fbd = new System.Windows.Forms.SaveFileDialog(); if (!string.IsNullOrEmpty(title)) { fbd.Title = title; } fbd.FileName = fbd.Title + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");//设置文件保存名称 if (!string.IsNullOrEmpty(fileName)) { fbd.FileName = fileName; } fbd.Filter = "Excel 文件(*.xls)|*.xls|Excel 文件(*.xlsx)|*.xlsx"; ;// "Excel|*.xls;*.xlsx;"; if (!string.IsNullOrEmpty(title)) { fbd.Title = title;// "保存为"; } if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { path = fbd.FileName; } return path; } } }