本帖最后由 chzj589 于 2019-11-21 18:11 编辑
优点:速度快。
#AutoIt3Wrapper_UseX64 = n
#include <Excel.au3>
Global $sFilePath = @ScriptDir & "\testA.txt"
Local $vara = @ScriptDir & "\快递单号.xlsx"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & $vara & ";Extended Properties='Excel 12.0'")
$aArray = $addfld.Execute("SELECT * FROM [Sheet1$]").GetRows
Local $iRowsA = UBound($aArray, $UBOUND_ROWS)
;_ArrayDisplay($aArray, "显示")
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("SELECT * FROM [Sheet1$]")
$sResult1 = $RS.Fields(1).value
Dim $a = 2, $b = 1, $c
For $i = 2 To $iRowsA
$sResult = $RS.Fields(1).value
$RS.movenext
$c &= $sResult & ","
Local $sString = StringTrimRight($c, 1)
If $a = 11 Then
IniWrite($sFilePath, "快递单号", "分组" & $b, $sString)
$a = 1
$c = ""
$b += 1
EndIf
If $i = $iRowsA Then IniWrite($sFilePath, "快递单号", "分组" & $b, $sString)
$a += 1
Next
MsgBox(0, $iRowsA&" 行", "写入完成", 1)
$RS.close
$addfld.Close
|