excel模板导出一个新的文件
string str = Application.StartupPath + "\\readiness form_0427.xlsx";
//路径
FileStream fs = new FileStream(str, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
ExcelPackage ep = new ExcelPackage(fs);
ExcelWorksheet sheet = ep.Workbook.Worksheets[1];
fs.Close();
//读完要关闭
//生成新的路径
string sr = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + @"\output\Report"+DateTime.Now.ToString("yyyy-MM-dd") +".xlsx";
if (!Directory.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + @"\output"))
{
// System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)
Directory.CreateDirectory((Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\output"));
}
using (fs = new FileStream(sr, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
ep.SaveAs(fs);//存档}
}
//生成后打开文件
ProcessStartInfo info = new ProcessStartInfo(sr);
System.Diagnostics.Process.Start(info);