我正在处理一个返回 excel 文件的操作 - excel 是使用 ComponentOne dll 创建的。
这是我到目前为止所拥有的
public ActionResult DownloadExcel()
{
C1XLBook testBook = new C1XLBook();
XLSheet s1 = testBook.Sheets[0];
MemoryStream ms = new MemoryStream();
testBook.Save(ms,FileFormat.Biff8);
return File(ms, "application/ms-excel");
}
但我收到一个无效的 Json 错误
在 JS 方面,我有以下代码
$.ajax({
contentType: 'application/json, charset=utf-8',
type: "POST",
url: /test/DownloadExcel,
cache: false,
dataType: "json",
success: function (response) {
alert("good");
},
error: function (xhr, ajaxOptions, thrownError) {
alert("error");
}
});
我究竟做错了什么?