We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unable to complete aspose.cells MVC C# download


I am going through an odd error using aspose.cells for ASP.NET (MVC Razor).

The application uses this tool while a user is logged in and also when a user is not. For some reason, aspose does not complete generating the excel document while the user is logged in. It will work on my local, however not on the server. I checked the folder permissions of where the templates are being read from and there aren’t any issues. The most odd part, was I did see it work twice, then constantly got this error.

In chrome: error in bottom download items
Failed. Network error

In firefox: Pop up error
C:\Users\User1\AppData\Local\Temp\u1KwTc14.xlsx.part could not be saved, because the source file could not be read.
Try again later, or contact the server administrator.

Any help will be gratefully appreciated!


I think your issue may not be linked with Aspose.Cells APIs. Anyways, you try the following things to figure out your issue:

  1. Please call Response.End after calling workbook.Save() method:
    Sample code:

//Save in Excel2007/2010/2013 XLSX file format
workbook.Save(Response, “Filename.xlsx”, ContentDisposition.Attachment, new OoxmlSaveOptions());

  1. Your issue can be related to configuration or rights issues on your server. Please make sure that you have administrative rights on the server. By the way, do you use Partial trust or medium trust level/mode on your live server. If this is the case, please run your project in full trust level permission set, see the document for your reference:

  2. If you still find the issue (even using the above points), please save the workbook to stream, then export it by Response object, see the following code:
    Sample code:

/Send workbook to response/
OoxmlSaveOptions xSaveOptions = new OoxmlSaveOptions(SaveFormat.Xlsx);

            MemoryStream tempStream = new MemoryStream();
           workbook.Save(tempStream, xSaveOptions);

            //set the position.
            tempStream.Position = 0;

            this.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
           this.Current.Response.AddHeader("content-disposition", "attachment; filename=out1.xlsx" );

MemoryStream ms = new MemoryStream();
workbook.Save(ms, new Aspose.Cells.XlsSaveOptions(Aspose.Cells.SaveFormat.Excel97To2003)); ;
this.Response.ContentType = “application/vnd.ms-excel”;
Response.AddHeader(“content-disposition”, “inline; filename=Book1.xls”);

Hope, this helps a bit.

Thank you.