最近做了一个Upload文件的需求,文件的格式为CSV,读取文件的方法整理了一下,如下:
1、先写了一个读取CSV文件的Function:
1 '读取CSV文件 2 '假设传入的参数strFile=C:\Documents and Settings\Administrator\桌面\TPA_Report1 - 副本.CSV 3 Public Function Read_CSVFile(strFile As String) As ADODB.Recordset 4 Dim rs As ADODB.Recordset 5 Set rs = New ADODB.Recordset 6 Dim conn As ADODB.Connection 7 Set conn = New ADODB.Connection 8 Dim strFilePath As String, strFileName As String 9 Dim i As Integer 10 i = Len(strFile) 11 Do Until Mid(strFile, i, 1) = "\" '从后向前查找倒数第一个"\" 12 i = i