发布网友 发布时间:2022-05-23 15:25
共1个回答
热心网友 时间:2023-10-27 07:55
用 Microsoft Access 就可以打开 CSV 文件的。 然后再保存成mdb就行了。 CSV、MDB格式转换程序: '/////////////////////////////////////////////////////// 'CSV < - >MDB Convert Tool 'Written By gyawjk '/////////////////////////////////////////////////////// Option Explicit Private Sub Command1_Click() On Error GoTo ErrHandler CommonDialog1.FileName = "" CommonDialog1.CancelError = True CommonDialog1.Filter = "CSV File(*.csv;*.txt)|*.csv;*.txt" CommonDialog1.ShowOpen If CommonDialog1.FileName <> "" Then Text1.Text = CommonDialog1.FileName End If Exit Sub ErrHandler: MsgBox "Error:" & Err.Description, vbCritical, "Error" End Sub Private Sub Command2_Click() On Error GoTo ErrHandler CommonDialog1.FileName = "" CommonDialog1.CancelError = True CommonDialog1.Filter = "Access File(*.mdb)|*.mdb" CommonDialog1.ShowOpen If CommonDialog1.FileName <> "" Then Text2.Text = CommonDialog1.FileName End If Exit Sub ErrHandler: MsgBox "Error:" & Err.Description, vbCritical, "Error" End Sub Private Sub Command3_Click() If Option1.Value = True Then If Dir(Text1.Text) = "" Then MsgBox "CSV文件不存在!", vbCritical, "错误" Exit Sub End If If CSV2MDB(Text1.Text, Text2.Text) = True Then MsgBox "导入表成功!", vbInformation, "提示" End If Else If Dir(Text2.Text) = "" Then MsgBox "CSV文件不存在!", vbCritical, "错误" Exit Sub End If If MDB2CSV(Text2.Text, Text1.Text, "Book1") Then MsgBox "导出CSV成功!", vbInformation, "提示" End If End If End Sub Private Function CSV2MDB(CSVFileName As String, MDBFileName As String, Optional TableName As String = "") As Boolean On Error GoTo ErrHandler Dim strTemp As String Dim strCSVFile As String, strCSVLineSplit As String Dim iCSVLineCount As Integer, iCSVFieldCount As Integer Dim strArrCSVLine() As String, strArrCSVHead() As String, strArr