我创建了这个 COM 对象:
using Microsoft.Office.Interop.Excel;
private Application app = null;
private Workbook workbook = null;
private Worksheet worksheet = null;
worksheet.Cells[1, 1] = "title ";
worksheet.Cells[2, 1] = "row 1 header";
worksheet.Cells[2, 2] = "row 1 header";
worksheet.Cells[2, 3] = "row 1 header";
worksheet.Cells[2, 4] = "row 1 header";
var i = 2;
foreach (var vm in model)
{
worksheet.Cells[i, 1] = "value";
worksheet.Cells[i, 2] = "value";
worksheet.Cells[i, 3] = "value";
worksheet.Cells[i, 4] = "value";
i++;
}
现在我有了这个 Excel.Application 对象,如何将它发送到浏览器以便用户下载它?