Statements for
Private Sub data export _Click (DGV As Object, As EventArgs e) Handles data export. Click
Dim SFD As New SaveFileDialog
SFD. Filter="CSV files files (*. CSV) | *. CSV"
'the SFD. The Filter="Excel file (*. XLS) | *. XLS | all files (*. *) | *. *"
Moban="template"
SFD. FileName=RadioButton1. Text & amp; Moban
SFD. FilterIndex=0
SFD. Title="save to CSV (comma separated) file"
SFD. InitialDirectory="F: \ flu upload "
SFD. RestoreDirectory=True
SFD. CreatePrompt=True
If SFD. ShowDialog=DialogResult. OK Then
Dim the fs As New IO. FileStream (SFD) FileName, IO. FileMode. Create)
Dim sw As New IO. StreamWriter (Unicode), fs System. Text. Encoding.
Dim the title As String=""
Dim As Integer I
'write a column header
For I=0 To DataGridView3. ColumnCount - 1
Title=DataGridView3. Columns (I). The HeaderText
Sw. Write (CRH (34))
Sw. Write (title)
Sw. Write (CRH (34))
Sw. Write (", ")
If I & lt;> Then DataGridView3. ColumnCount - 1
End the If
Next
Sw. WriteLine (" ")
Dim x As Integer
Dim y As Integer
For x=0 To DataGridView3. RowCount - 1
For y=0 To DataGridView3. ColumnCount - 1
If DataGridView3. Rows (x) Cells (y). The Value Is DBNull. Value Then
Sw. Write (" ")
The Else
Sw. Write (CRH (34))
Sw. Write (DataGridView3. Rows (x) Cells (y) Value)
Sw. Write (CRH (34))
Sw. Write (", ")
End the If
If y & lt;> Then DataGridView3. ColumnCount - 1
End the If
Next
'DataGridView3. Columns (lm). The HeaderText=""
Sw. WriteLine (" ")
Sw. Flush ()
'If DataGridView3. Columns (lm). The Name=lm Then
'DataGridView3. Columns (lm). The Visible=False
Next
Fs. The Close ()
MessageBox. Show (" export success ", "prompt")
End the If
End Sub
The database directly export CSV file
After debugging tools export CSV file
Compared with direct export "" and, less time format is not for the great spirit guide
CodePudding user response:
Debugging, CRH (34) is the quotesCodePudding user response: