Wilder1626
asked on
Extract DataGridView1 to text file No 2
Hello again.
I'm openning a second topic with a similar subject, but with one detail more.
Extract DataGridView1 to text file
No, i can extract from a GridView to a text file.
But now, i need to also extract the grid to a text file this way:
From column 1 to 10 of the grid would be transfered to the text file on one row and from column 11 to 15 just under that row in the same text file..
And this, for every grid row.
Is that posible to do?
Thanks again for your help.
I'm openning a second topic with a similar subject, but with one detail more.
Extract DataGridView1 to text file
No, i can extract from a GridView to a text file.
But now, i need to also extract the grid to a text file this way:
From column 1 to 10 of the grid would be transfered to the text file on one row and from column 11 to 15 just under that row in the same text file..
And this, for every grid row.
Is that posible to do?
Dim xOut As New Dictionary(Of Integer, Integer) From {{0, 1}, {1, 1}, {2, 1}, {3, 12}, {4, 12}, {5, 1}, {6, 35}, {7, 35}, {8, 20}, {9, 1}, {10, 35}, {11, 35}, {12, 20}, {13, 8}, {14, 12}, {15, 5}}
Dim MyPath As String = "C:\Documents and Settings\All Users\Desktop\tl.02" & Format(Now, "yymmddhhmmss")
Dim xBuilder As New StringBuilder
For Each row As DataGridViewRow In Me.DataGridView1.Rows
Dim xList As String = Nothing
For x = 0 To row.Cells.Count - 1
Dim xValue = row.Cells(x).Value.ToString
If xValue.Length < xOut.Item(x) Then xValue = xValue.PadRight(xOut.Item(x))
xBuilder.Append(xValue)
Next
xBuilder.Append(vbCrLf)
Next
File.WriteAllText(MyPath, xBuilder.ToString)
Thanks again for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is perfect.