Xls导出未在服务器上运行

时间:2016-08-02 20:46:34

标签: c# asp.net-mvc azure xls

 public ActionResult ExportToExcel()
    {   
        GridView gv = new GridView();
        gv.DataSource = db.Details.Select(x => new
        {
            x.Title,
            Category = x.Category.Title,
            SubCategory = x.SubCategory.Title,
            x.Count,
            x.Price,
            Automobiles = x.Automobiles.Count,
            x.Description
        }).ToList();
        gv.DataBind();
        Response.ClearContent();
        Response.Buffer = true;            
        Response.AddHeader("content-disposition", "attachment; filename=Marklist.xls");
        Response.ContentType = "application/ms-excel";
        Response.Charset = "";
        StringWriter sw = new StringWriter();
        HtmlTextWriter htw = new HtmlTextWriter(sw);
        gv.RenderControl(htw);
        Response.Output.Write(sw.ToString());
        Response.Flush();
        Response.End();
        return Json(true);
    }

出口在当地运作良好。它不适用于Azure。下载一个空文件。告诉我这个问题是什么?

1 个答案:

答案 0 :(得分:0)

您的问题可能与最近的Microsoft Microsoft Excel安全更新有关。

请参阅... https://stackoverflow.com/a/38467132/6610346