正在导出 excel 份报告

Exporting excel reports

我准备了一个软件,我在其中通过 ASP.NET 中的代码导出 excel 报告。 现在我正在 Localhost 上开发整个,所以当我导出报告时它正在我的 PC 上下载。 我只是担心如果我 运行 它在实时服务器上并且比我导出 excel 报告,它会下载到我的电脑上还是服务器上。

  public ActionResult ExportToExcel()
        {
            if (!General.ValidateSession())
            {
                return RedirectToAction("Login", "User");
            }
            string fDate = TempData["FromDate"].ToString();
            string tDate = TempData["toDate"].ToString();
            var grdview = new GridView();
            grdview.DataSource = this.GetList();
            grdview.DataBind();
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename= " + fDate + " - " + tDate + ".xls ");
            Response.ContentType = "application/ms-excel";
            Response.Charset = "";
            StringWriter strWriter = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(strWriter);
            grdview.RenderControl(htmlWriter);
            Response.Output.Write(strWriter.ToString());
            Response.Flush();
            Response.End();
            return RedirectToAction("DateRecords");
        }

当您在服务器上托管应用程序并在 EXCEL 导出时,文件将从服务器下载到用户的计算机。不在您的本地计算机上!