Using the latest version of GemBox installed from NuGet.
Here is the error:
Error
{“Thread was being aborted.”}
Data: {System.Collections.ListDictionaryInternal}
ExceptionState: Unable to evaluate expression because the code is optimized or a native frame is
on top of the call stack.
HResult: -2146233040
HelpLink: Nothing
InnerException: Nothing
Message: “Thread was being aborted.”
Source: “mscorlib”
StackTrace:
" at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)" & vbCrLf &
" at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)" & vbCrLf & "
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)" & vbCrLf &
" at " & ChrW(3) & " ." & ChrW(2) & "[TSaveOptions](Object " & ChrW(2) & ", String " & ChrW(3) & ", TSaveOptions " & ChrW(5) & ", String " & vbBack & “, Boolean " & ChrW(6) & “, Action`2 " & ChrW(14) & “)” & vbCrLf &
" at GemBox.Spreadsheet.ExcelFile.Save(Object httpResponse, String fileName, SaveOptions options)” & vbCrLf &
" at Admin_Registrations_RegistrationList.btnExportList_Click(Object sender, EventArgs e) in C:\DevOps\IDMI\UHEMS\EventRegistration\Main\Webroot\Admin\Registrations\RegistrationList.aspx.vb:line 184”
TargetSite: {System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)}
The code that I’m using is the following:
Protected Sub btnExportList_Click(sender As Object, e As EventArgs) Handles btnExportList.Click
Dim objExcel As ExcelFile
Dim dset As DataSet
objExcel = ExcelFile.Load(MapPath(ConfigurationManager.AppSettings("AdministrationPath") & "/Assets/Registration_Export.xlsx"))
Dim xlSheet As ExcelWorksheet = objExcel.Worksheets(0)
Dim idxRow As Integer = 1
Dim csCenter As CellStyle = New CellStyle
Dim csCurrency As CellStyle = New CellStyle
Dim csCategory As CellStyle = New CellStyle
csCenter.HorizontalAlignment = HorizontalAlign.Center
csCurrency.HorizontalAlignment = HorizontalAlign.Right
dset = RegistrationTools.GetList(ddlEvents.SelectedValue)
Dim objEvent As New NewEvent(ddlEvents.SelectedValue)
For Each row As DataRow In dset.Tables(0).Rows
xlSheet.Cells(idxRow, 0).Value = ddlLocations.SelectedItem.Text
xlSheet.Cells(idxRow, 1).Value = objEvent.EventStartDate.ToShortDateString
xlSheet.Cells(idxRow, 2).Value = objEvent.EventName
xlSheet.Cells(idxRow, 3).Value = row("RegistrationDate").ToString
xlSheet.Cells(idxRow, 4).Value = row("FirstName").ToString & " " & row("LastName").ToString
xlSheet.Cells(idxRow, 5).Value = ""
xlSheet.Cells(idxRow, 6).Value = ""
xlSheet.Cells(idxRow, 7).Value = ""
xlSheet.Cells(idxRow, 8).Value = ""
xlSheet.Cells(idxRow, 9).Value = ""
xlSheet.Cells(idxRow, 10).Value = ""
xlSheet.Cells(idxRow, 11).Value = ""
xlSheet.Cells(idxRow, 12).Value = ""
xlSheet.Cells(idxRow, 13).Value = ""
xlSheet.Cells(idxRow, 14).Value = ""
xlSheet.Cells(idxRow, 15).Value = ""
xlSheet.Cells(idxRow, 16).Value = ""
xlSheet.Cells(idxRow, 17).Value = ""
If Not Convert.IsDBNull(row("EMailAddress")) Then xlSheet.Cells(idxRow, 5).Value = row("EMailAddress").ToString
If Not Convert.IsDBNull(row("AddressLine1")) Then xlSheet.Cells(idxRow, 6).Value = row("AddressLine1").ToString
If Not Convert.IsDBNull(row("AddressLine2")) Then xlSheet.Cells(idxRow, 7).Value = row("AddressLine2").ToString
If Not Convert.IsDBNull(row("AddressCity")) Then xlSheet.Cells(idxRow, 8).Value = row("AddressCity").ToString
If Not Convert.IsDBNull(row("AddressState")) Then xlSheet.Cells(idxRow, 9).Value = row("AddressState").ToString
If Not Convert.IsDBNull(row("AddressZipCode")) Then xlSheet.Cells(idxRow, 10).Value = row("AddressZipCode").ToString
If Not Convert.IsDBNull(row("PhoneHome")) Then xlSheet.Cells(idxRow, 11).Value = row("PhoneHome").ToString
If Not Convert.IsDBNull(row("PhoneWork")) Then xlSheet.Cells(idxRow, 12).Value = row("PhoneWork").ToString
If Not Convert.IsDBNull(row("PlaceOfEmployment")) Then xlSheet.Cells(idxRow, 13).Value = row("PlaceOfEmployment").ToString
If Not Convert.IsDBNull(row("Department")) Then xlSheet.Cells(idxRow, 14).Value = row("Department").ToString
If Not Convert.IsDBNull(row("CertificationExpiryBCLS")) Then xlSheet.Cells(idxRow, 15).Value = row("CertificationExpiryBCLS").ToString
If Not Convert.IsDBNull(row("CertificationExpiryACLS")) Then xlSheet.Cells(idxRow, 16).Value = row("CertificationExpiryACLS").ToString
If Not Convert.IsDBNull(row("AccountNumber")) Then xlSheet.Cells(idxRow, 17).Value = row("AccountNumber").ToString
idxRow += 1
Next
Response.Clear()
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Try
objExcel.Save(HttpContext.Current.Response, "Registration_Export.xlsx", XlsSaveOptions.XlsxDefault)
'objExcel.Save("Registration_Export.xlsx") -- i tried this and didn't work either
Catch ex As Exception
Dim int As Integer = 1 -- this is just so I could catch the error
End Try
End Sub
I’ve looked at several examples on the website and can’t find a reason why this is occurring… Could definitely use some help on this one!