把分组最后一个数字后面的“,”去掉
#include <Excel.au3>
Global $sFilePath = @ScriptDir & "\test.txt";@ScriptDir & "\_IniLtest.ini"
Local $vara = @ScriptDir & "\test.xlsx"
$oExcel = ObjCreate("excel.application")
$oExcel.visible = 0;True
$oWorkbook = $oExcel.workbooks.open($vara)
Local $iRowsA = $oWorkbook.ActiveSheet.UsedRange.Rows.Count; ‘当前工作表中已使用的行数
Dim $a = 1, $b = 1, $c
For $i = 2 To $iRowsA
;$sResult = _ExcelReadCell($oWorkbook, $i, 2)
$sResulta = _Excel_RangeRead($oWorkbook, Default, "B" & 1)
$sResult = _Excel_RangeRead($oWorkbook, Default, "B" & $i)
$c &= $sResult & ","
Local $sString = StringTrimRight($c, 1) ; 删除字符串右起 1个字符.
If $a = 10 Then
IniWrite($sFilePath, $sResulta, "分组" & $b, $sString)
$a = 1
$b += 1
$c = ""
EndIf
If $i = $iRowsA Then IniWrite($sFilePath, $sResulta, "分组" & $b, $sString)
$a += 1
Next
MsgBox(0, $iRowsA, "写入完成" ,1)
_Excel_Close($oExcel)
|