private ActionResult GenerateCAReport(List <CAExcelReportItem> items, string wsName) { using (Excel xl = new Excel()) { xl.AddDataWorksheet <CAExcelReportItem>(wsName, items); MemoryStream ms = xl.getMemoryStream(); string filename = wsName.Replace(" ", "") + ".xls"; return(File(ms, "application/msexcel", filename)); } }