ado 读取exce后修改另存l
程序代码:
Private Sub Command1_Click() Set xlapp = CreateObject("Excel.Application") Set xlBook = xlapp.Workbooks.Add Set xlSheet = xlBook.Worksheets(1) Dim con As Object Dim rs As Object Set con = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") Keystr = "%" & "AA" & "%" con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source = " & App.Path & "\a.xls;Extended Properties='Excel 8.0;HDR=Yes'" con.Open Sql = "select 姓名,综合 from [test$] where 项目 like '" & Keystr & "'" rs.Open Sql, con, 3, 3 For I = 1 To rs.Fields.Count xlSheet.Cells(1, I) = rs.Fields(I - 1).Name Next xlSheet.Cells(2, 1).CopyFromRecordset rs xlBook.SaveAs ("G:\b.xls") xlBook.Close xlapp.Application.Quit Set xlapp = Nothing Set xlSheet1 = Nothing Set xlBook = Nothing rs.Close Set rs = Nothing con.Close Set con = Nothing End Sub
读取a.xls,想把a.xls中某一列的数值提取后,放在最后一列. 再另存为b.xls
数据量很大,不知如何通过高效的方法来实现
请各位大神指导..
附件中b.xls为需实现的效果。
Test.rar
(3.54 KB)