|
An example once written for the reference of the landlord, this speed is very fast! Even if you export 576*20 data in a few seconds
It is strongly recommended that the landlord use the CSV file format to export the table file.
It is a formatted text file, the general format is: the text line represents the table line
The contents separated by commas on the same line represent the contents of different fields.
The landlord can save an ordinary EXCEL file and choose to save it as a CSV format, then open the file in WordPad and take a look at the format to know, it is very simple. And the speed of doing so is also very fast, which is not comparable to writing data one by one.
When creating a data interface, you can create an array of string type, first put all the contents in the array, and then use the loop to write to the file.
The file processing time of hundreds of thousands of records is only a few seconds
To add: the CSV file you generated, the icon displayed on the system with OFFICE is an EXCEL icon (slightly different, there is a lowercase "a" under the icon), indicating that OFFICE has put this The file is registered as the default openable file type.
Need to study carefully, learn and apply! ! ! ! ! ! ! ! ! !
Rem quickly saves the data file format CSV, which can be opened with EXCEL
Private Sub MnuCsv_Click()
Dim i As Integer
'Form
Dim myPic As StdPicture
Set myPic = CapturePic(Picture1)
SavePicture myPic, "c:\myPic.bmp"
''Write a CSV file, a file that Excel can open
Open "D:\11.csv" For Output As #1
Print #1, "Step sequence number"; ",";''''''Here is the first line of CSV, fixed column header
Print #1, "nx"; ",";
Print #1, "αi"; ",";
Print #1, "Turn radius of tooth tip"; ",";
Print #1, "Fc"; ",";
Print #1, "Fh"; ",";
Print #1, "Fdt"; ",";
Print #1, "Fdn"; ",";
Print #1, "Fo"; ",";
Print #1, vbNullString''''End newline
''''''data input
For i = 1 To 546
Print #1, Val(MSFlexGrid1.TextMatrix(i, 0)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 1)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 2)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 3)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 4)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 5)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 6)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 7)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 8)); ",";
Print #1, vbNullString
Next
Close #1
End Sub
Open and save the file:
Rem quickly saves the data file format CSV, which can be opened with EXCEL
Private Sub MnuCsv_Click()
Dim i As Integer
'Form
Dim myPic As StdPicture
Set myPic = CapturePic(Picture1)
SavePicture myPic, "c:\myPic.bmp"
''Write a CSV file, a file that Excel can open
Dim FileName As String'''''''''''Save the data to an Excel table
CommDiag1.FileName = ""
CommDiag1.Filter = "CSV|*.csv"
CommDiag1.ShowSave
FileName = CommDiag1.FileName
If FileName = "" Then
Exit Sub
End If
Open FileName For Output As #1
Print #1, "Step sequence number"; ",";''''''Here is the first line of CSV, fixed column header
Print #1, "nx"; ",";
Print #1, "αi"; ",";
Print #1, "Turn radius of tooth tip"; ",";
Print #1, "Fc"; ",";
Print #1, "Fh"; ",";
Print #1, "Fdt"; ",";
Print #1, "Fdn"; ",";
Print #1, "Fo"; ",";
Print #1, vbNullString''''End newline
''''''data input
For i = 1 To 546
Print #1, Val(MSFlexGrid1.TextMatrix(i, 0)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 1)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 2)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 3)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 4)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 5)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 6)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 7)); ",";
Print #1, Val(MSFlexGrid1.TextMatrix(i, 8)); ",";
Print #1, vbNullString
Next
Close #1
End Sub |
|