Environment: Visual Studio 2015 / .net 4.5.1
I am trying to create an excel file from my vb.net application.
I am populating the file with database records.
I was able to populate column A, but could not populate the rest of the columns.
I got the code from docs.microsof.com and the code is failing here when it is time to populate the second column. I was populating it with same value as column A, so the problem is not record-related.
I removed the error handling (try...catch) and got an error on the highlighted line: Check to determine if the object is null before calling the method and Use the "new" keyword to create an object instance
' If there is not a cell with the specified column name, insert one.
If (row.Elements(Of Cell).Where(Function(c) c.CellReference.Value = columnName + rowIndex.ToString()).Count() > 0) Then
Return row.Elements(Of Cell).Where(Function(c) c.CellReference.Value = cellReference).First()
Else
' Cells must be in sequential order according to CellReference. Determine where to insert the new cell.
Dim refCell As Cell = Nothing
For Each cell As Cell In row.Elements(Of Cell)()
If (String.Compare(cell.CellReference.Value, cellReference, True) > 0) Then
refCell = cell
Exit For
End If
Next
Any help in resolving this issue is greatly appreciated.
I am trying to create an excel file from my vb.net application.
I am populating the file with database records.
I was able to populate column A, but could not populate the rest of the columns.
I got the code from docs.microsof.com and the code is failing here when it is time to populate the second column. I was populating it with same value as column A, so the problem is not record-related.
I removed the error handling (try...catch) and got an error on the highlighted line: Check to determine if the object is null before calling the method and Use the "new" keyword to create an object instance
' If there is not a cell with the specified column name, insert one.
If (row.Elements(Of Cell).Where(Function(c) c.CellReference.Value = columnName + rowIndex.ToString()).Count() > 0) Then
Return row.Elements(Of Cell).Where(Function(c) c.CellReference.Value = cellReference).First()
Else
' Cells must be in sequential order according to CellReference. Determine where to insert the new cell.
Dim refCell As Cell = Nothing
For Each cell As Cell In row.Elements(Of Cell)()
If (String.Compare(cell.CellReference.Value, cellReference, True) > 0) Then
refCell = cell
Exit For
End If
Next
Any help in resolving this issue is greatly appreciated.