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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
Sub GridView2CSV(ByVal myGridview As GridView, ByVal File As String)
''// Get the Columns of the Gridview
Dim ColumnsCount As Integer = myGridview.Columns.Count - 1
''// Get and Write the HeaderNames
Dim HeaderNames As String = Nothing
For i = 0 To ColumnsCount
HeaderNames += myGridview.Columns(i).HeaderText & ";"
Next
CW(HeaderNames, File)
''// Get the Rows Content
Dim RowValue As String = Nothing
For Each myRow As GridViewRow In myGridview.Rows
For i = 0 To ColumnsCount
RowValue += myRow.Cells(i).Text & ";"
Next
CW(RowValue, File)
RowValue = Nothing
Next
End Sub
Sub CW(ByVal Text, ByVal FileName)
Dim myFileWriter As New System.IO.StreamWriter(FileName, True)
myFileWriter.WriteLine(Text)
myFileWriter.Close()
End Sub
End Class
|