vb.net 中 datagridview的数据如何保存到 txt
1个回答
展开全部
Dim i As Integer
Dim j As Integer
Dim myFile As New System.IO.StreamWriter("c:\Test.txt")
Dim strTemp As String = ""
For j = 0 To frmQuery.DataGridView1.RowCount - 1
strTemp = ""
For i = 0 To frmQuery.DataGridView1.Columns.Count - 1
strTemp &= "'" & frmQuery.DataGridView1(i, j).Value & "'" & ","
Next
myFile.WriteLine(strTemp)
Next
myFile.Close()
格式为表格每行保存为文本文件的一行,字段之间以逗号分隔。
Dim j As Integer
Dim myFile As New System.IO.StreamWriter("c:\Test.txt")
Dim strTemp As String = ""
For j = 0 To frmQuery.DataGridView1.RowCount - 1
strTemp = ""
For i = 0 To frmQuery.DataGridView1.Columns.Count - 1
strTemp &= "'" & frmQuery.DataGridView1(i, j).Value & "'" & ","
Next
myFile.WriteLine(strTemp)
Next
myFile.Close()
格式为表格每行保存为文本文件的一行,字段之间以逗号分隔。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询