私が実装しようとしているのは、ファイル保存ダイアログを使用して、ユーザーがグリッド データを Excel ファイルにエクスポートしてダウンロードできるようにすることです。
これが私が今それをどのようにコーディングしたかです-
JavaScriptで -
$.post("/irn/Identifier/Download", { "columnValues": columnValues });
識別子コントローラのダウンロード アクションで -
public FileResult Download(string columnValues)
{
DTData headlineRows = (DTData)Newtonsoft.Json.JsonConvert.DeserializeObject(columnValues, typeof(DTData));
var e = new Services.DownloadToExcel();
return File(e.WriteData(headlineRows), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "testfile.xlsx");
}
DownloadToExcel クラスの WriteData 関数内にある -
//Here, I'm using the EPPlus library to write the column data to an excel file and then i'm returning the data as a byte array -
//Some code that writes the data
return packages.GetAsByteArray();
このコードを実行すると、ブラウザにファイル保存ダイアログが表示されるはずですが、何も起こりません。C# または JavaScript 側にエラーはありません。誰かが私が間違っている可能性があることを教えてもらえますか?