Starr Duskk
asked on
Lumenworks CSV Writer
I have been looking for an example of how to use Lumenworks to CREATE a CSV file. I've only see how to read one.
Can someone please send me to an example or show me how to use Lumenworks to create a CSV file?
I then need to send the CSV file to the screen for the user to download.
thanks!
Can someone please send me to an example or show me how to use Lumenworks to create a CSV file?
I then need to send the CSV file to the screen for the user to download.
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Why use something that you don't need to?
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/d8a2ffc2-3782-46dc-bc97-e0b5cdf9ad29/
Public Sub ExportDataTableToCsv(target As DataTable, outputFile As String)
Dim writer As New System.IO.StreamWriter(outputFile, False)
For rowIndex As Integer = 0 To target.Rows.Count - 1
For columnIndex As Integer = 0 To target.Columns.Count - 1
Dim fieldValue As Object = target.Rows(rowIndex).Item(columnIndex)
If Not IsDBNull(fieldValue) Then
Dim output As String = fieldValue.ToString
If output.Contains(","c) Then
writer.Write(ControlChars.Quote)
writer.Write(output)
writer.Write(ControlChars.Quote)
Else
writer.Write(output)
End If
End If
If columnIndex < target.Columns.Count - 1 Then
writer.Write(",")
End If
Next
If rowIndex < target.Rows.Count - 1 Then
writer.WriteLine()
End If
Next
writer.Close()
End Sub
http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/d8a2ffc2-3782-46dc-bc97-e0b5cdf9ad29/
test
ASKER