Home All Groups Group Topic Archive Search About
Author
7 Nov 2006 9:20 PM
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()

Author
8 Nov 2006 4:30 PM
Spam Catcher
"Stranger3" <u28800@uwe> wrote in news:68f2ccb6bf0a3@uwe:

> 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.

Take a look at FileHelpers on SourceForge.