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

Free Support Forum - aspose.com

ThreadAbortException Inside Try...Catch

Hello,

I am using Aspose.Cells version 4.5.1.2 in a web application. When attempting to save a workbook in Excel 2007 format, I receive a ThreadAbortException on workbook.save. This works fine when saving in Excel 2003 format.

I am calling a function that creates a new workbook, writes data to it and saves it from the Page_Load event. If I add a try...catch around the call to the function that generates the Excel file, I get a ThreadAbortException. If I remove the try...catch, the file opens with no problems. Please see the sample code below...

Protected Sub RenderReport_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

Try

Excel2007Test()

Catch ex As Exception

End Try

End Sub

Private Function Excel2007Test()

Dim oWorkbook As New Aspose.Cells.Workbook()

Dim oLicense As Aspose.Cells.License = New Aspose.Cells.License()

oLicense.SetLicense("Aspose.Cells.lic")

oWorkbook.Worksheets(0).Cells(0, 0).PutValue("TEST!")

oWorkbook.Save("test.xlsx", SaveType.OpenInExcel, FileFormatType.Excel2007Xlsx, Me.Response)

oWorkbook = Nothing

oLicense = Nothing

End Function

Thanks in advance for your assistance.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. I checked your provided code with this latest version and it worked fine.

Thank You & Best Regards,

Thank you for the quick response.

I still get a ThreadAbortException with the version you provided. If there is nothing inside the Catch, the exception is thrown, but the file still opens. In our code, we are handling the exception and redirecting the user to a standard error page. So, the file is still not opening.

Thanks again for any assistance you can provide.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

After further testing, we have found the issue you have mentioned. We will fix it soon.

Thank You & Best Regards,

Hi,

Please try the attached version(4.5.1.23). We have removed this ThreadAbortException exception. In order to avoid Response object to write some additional data (e.g.., html tags etc.) to the streams, we used to call Response.End method to end the response in the previous versions. So, if there is any codes after Workbook.Save() method, this error would be thrown. Now, we use Response.Close() method to close the response object and this issue is no longer there.

Thank you.

Sorry for taking so long to respond. This works perfectly.

Thank you very much for the quick responses and fix.