Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Issue with creating Excel file using XML

Issue with creating Excel file using XML

Issue with creating Excel file using XML

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()
' 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

Any help in resolving this issue is greatly appreciated.

RE: Issue with creating Excel file using XML

Sorry, I mean Using OpenXML

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close