S
Stranger3
I am trying to create a comma delimited file from visual basic .net and then
open it from excel for further processing.
The problem I am running into so far is that after the file is created,
nothing is written to it.
Please help me and thank you in advance.
My code is shown below:
Dim output As New StreamWriter(pth, False)
Dim delim As String
'write out the header row
delim = ""
Dim text As String = ""
For Each col As DataColumn In dsvendorontime.Tables(2).Columns
output.Write(delim)
output.Write(col.ColumnName)
delim = ","
text = text + delim + col.ColumnName
Next
output.WriteLine(text)
'write out each data row
For Each row As DataRow In dsvendorontime.Tables(2).Rows
delim = ""
For Each value As Object In row.ItemArray
output.Write(delim)
If TypeOf value Is String Then
output.Write(""""c)
' output.Write(value)
'output.Write(""""c)
Else
output.Write(value)
End If
delim = ","
Next
output.WriteLine()
Next
output.Close()
open it from excel for further processing.
The problem I am running into so far is that after the file is created,
nothing is written to it.
Please help me and thank you in advance.
My code is shown below:
Dim output As New StreamWriter(pth, False)
Dim delim As String
'write out the header row
delim = ""
Dim text As String = ""
For Each col As DataColumn In dsvendorontime.Tables(2).Columns
output.Write(delim)
output.Write(col.ColumnName)
delim = ","
text = text + delim + col.ColumnName
Next
output.WriteLine(text)
'write out each data row
For Each row As DataRow In dsvendorontime.Tables(2).Rows
delim = ""
For Each value As Object In row.ItemArray
output.Write(delim)
If TypeOf value Is String Then
output.Write(""""c)
' output.Write(value)
'output.Write(""""c)
Else
output.Write(value)
End If
delim = ","
Next
output.WriteLine()
Next
output.Close()