-2
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では動作しません。空のファイルをダウンロードしています。何が問題なのか教えてください。Xlsエクスポートはサーバー上で実行されていません
これはCOMを使用していますか? – evilSnobu
また、これをローカルに動作させるためにExcelがインストールされている必要がありますか? – evilSnobu
@evilSnobuいいえ、明らかにCOMまたはExcel Interopは使用していません。 – mason