I have an Action in my controller, I am trying to offer the user the created excel file after it is created. there is either something wrong with the mimetype or How I am setting up the workbook, I saw there were save options for workbook.save() but didn't know which options I needed to set to get this to work, if any. Thanks in advance!
public ActionResult RentRollExcel(int id) { var property = _db.Properties.Find(id);
var workBook = new Workbook(WorkbookFormat.Excel2007Template); var fileName = property.Name + "-RentRoll"; workBook.Worksheets.Add(fileName); var stream = new MemoryStream(); workBook.Save(stream); return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); }
Hello Landrum,
Thank you for contacting Infragistics!
Since you are creating Excel Template the Mime type should be also for template.
You can say stream.ToArray() in order to write ti to result.
1 2 3 4 5 6 7 8 9 10 11 12 13
public ActionResult RentRollExcel(int id) { var property = _db.Properties.Find(id); var workBook = new Workbook(WorkbookFormat.Excel2007Template); var fileName = property.Name + "-RentRoll"; workBook.Worksheets.Add(fileName); var stream = new MemoryStream(); workBook.Save(stream); return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.template"); }
Let me know if you need further assistance.