The component should work fine with Asp.net mvc. Could you try to remove all coding lines about Aspose.Cells and simply export the excel file with .NET’s System.IO objects if it works fine. In this way, you may trace your issue.
I know this is a fairly old post but I was looking for exactly the same answer and there does not appear to be many questions regarding MVC in the forum at the moment.
I managed to get this working correctly so figured I would post the result in case anyone else is looking.
As has been mentioned, you need to use a stream to output the resulting Excel file to the browser. The following code creates a basic Excel file from the controller and uses the Save method of the workbook to save the file to a stream. This stream is then outputted to the OutputStream of the ResponseBase object.
Function ExportExcelFile() As ActionResult
Dim workbook As New Workbook
Dim workSheet As Worksheet = workbook.Worksheets(“Sheet1”)
worksheet.Cells(0, 0).PutValue(“Test String”)
Dim stream As New System.IO.MemoryStream
Dim fileName As String = “Test.xls”
'Return whatever is applicable
Private Sub ExportExcelFileToResponse(ByVal stream As System.IO.MemoryStream, ByVal fileName As String)
ControllerContext.HttpContext.Response.AddHeader(“Content-disposition”, “attachment; filename=” & fileName & “;”)
An approach that I've used and simpler is:
stream.Position = 0;
return File(stream, "application/vnd.ms-excel", "junk.xls");