-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExport Text.txt
30 lines (27 loc) · 1.12 KB
/
Export Text.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Dim Path As String = INI_File.GetString("Setting", "Path", "")
'i am trying to export data from datagridview to the text file, for that my code is
Dim numCols As Integer = dgv_Data.ColumnCount
Dim numRows As Integer = dgv_Data.RowCount - 1
Dim strDestinationFile As String = "" & Path & "\" & "FordExport.txt"
Dim tw As TextWriter = New StreamWriter(strDestinationFile)
'writing the header
For count As Integer = 0 To numCols - 1
tw.Write(dgv_Data.Columns(count).HeaderText)
If (count <> numCols - 1) Then
tw.Write(",")
End If
Next
tw.WriteLine()
For count As Integer = 0 To numRows - 1
For count2 As Integer = 0 To numCols - 1
tw.Write(dgv_Data.Rows(count).Cells(count2).Value)
If (count2 <> numCols) Then
tw.Write(
""",""")
End If
Next
tw.WriteLine()
Next
tw.Close()
MsgBox(
"data exported to the textfile succsessfully")