本帖最后由 空城的守望 于 2013-10-24 09:06 编辑 #include <excel.au3>
$sFilePath = @ScriptDir & "\test.xls"
$oExcel = _ExcelBookOpen ($sFilePath,1,False)
;$oExcel.WorkSheets(2).Select
Dim $i=1,$j=4
Dim $yalurow=$oExcel.activesheet.usedrange.rows.count
While $i<=$yalurow
If StringStripWS( _ExcelReadCell($oExcel, $i, 7), 8)="发运订单" Then
$oExcel.sheets("data").Cells($j, 2).Value = $oExcel.Sheets("yalu").Cells($i + 2, 2).Text
$oExcel.sheets("data").Cells($j, 3).Value = $oExcel.Sheets("yalu").Cells($i + 2, 2).Text
$oExcel.sheets("data").Cells($j, 4).Value = $oExcel.Sheets("yalu").Cells($i + 2, 8).Text
$oExcel.sheets("data").Cells($j, 6).Value = StringStripWS( $oExcel.Sheets("yalu").Cells($i + 2, 4).Text, 8)
$oExcel.sheets("data").Cells($j, 26).Value = "电子秤;" & $oExcel.Sheets("yalu").Cells($i + 1, 2).Text
$i = $i + 9
Do
If $oExcel.Sheets("yalu").Cells($i, 1).Text = "总数量" Then
$oExcel.sheets("data").Cells($j, 9).Value = $oExcel.Sheets("yalu").Cells($i, 2).Text
$i = $i + 2
$j = $j + 1
ExitLoop
Else
$i=$i+1
EndIf
Until $i >= $yalurow
EndIf
Sleep(1000)
WEnd
_ExcelBookSave($oExcel)
$oExcel.WorkSheets(2).Select
MsgBox(0, "提示", "excel转换完成")
_ExcelBookClose($oExcel)
为什么我加了$oExcel.WorkSheets(2).Select,我的程序就不能运行了,而且不加sleep(100),cpu占有率75左右,但我的循环不是死循环啊 |