View Single Post
Join Date: Jun 2006
Posts: 45
Reputation: Oxiegen is an unknown quantity at this point 
Solved Threads: 3
Oxiegen Oxiegen is offline Offline
Light Poster

Re: Export DataTable to Excel with variable number of fields

 
0
  #2
Dec 5th, 2007
Problem solved.
I simply added a funktion that returns the string containing the values.

By calling the funktion like this:
  1. values = DataValues(row, dt.Columns.Count - 1)
The information is returned like this:
  1. Private Function DataValues(ByVal DRow As DataRow, ByVal Max As Integer) As String
  2. Dim retVal As String
  3.  
  4. retVal = "'" & DRow.Item(0) & "',"
  5. For i As Integer = 1 To Max - 1
  6. retVal &= "'" & DRow.Item(i) & "',"
  7. Next
  8. retVal &= "'" & DRow.Item(Max) & "'"
  9.  
  10. Return retVal
  11. End Function
Reply With Quote