【问题标题】:How to specify default path for saveAs dialog box for export excel from .net如何为从 .net 导出 excel 的另存为对话框指定默认路径
【发布时间】:2014-09-29 23:07:33
【问题描述】:
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();

我希望“另存为”对话框显示默认的指定路径,例如c:\users\joe\ 或将文件保存在指定目录中?我该怎么做?

【问题讨论】:

    标签: .net excel export closedxml


    【解决方案1】:

    您可以尝试为您的应用程序对象设置DefaultFilePath

    wb.Application.DefaultFilePath = @"c:\users\joe";
    

    来源:How to: Get and Set the Default File Path for Workbooks

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-23
      • 1970-01-01
      • 2014-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多