HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Current.Response.AddHeader("content-disposition", String.Format(@"attachment;filename={0}.xlsx", sheetName.Replace(" ", "_")));
using (var memoryStream = new MemoryStream())
{
wb.SaveAs(memoryStream);
memoryStream.WriteTo(HttpContext.Current.Response.OutputStream);
memoryStream.Close();
}
HttpContext.Current.Response.End();
我想要SaveAs对话框显示默认指定路径,例如c:\ users \ joe \或将文件保存在指定目录中?我怎么能这样做?
答案 0 :(得分:0)
您可以尝试为Application对象设置DefaultFilePath
。
wb.Application.DefaultFilePath = @"c:\users\joe";