#include <Excel.au3>
#include <array.au3>
Opt("wintitlematchmode",3)
$sFilePath1 = "C:\test.xlsx" ;该文件应该已存在
$oExcel1 = _ExcelBookOpen($sFilePath1,0)
For $i = 1 To 5;循环
$sCellValue1 = _ExcelReadCell($oExcel1, $i, 3)
$sCellValue2 = _ExcelReadCell($oExcel1, $i, 4)
if $sCellValue1>0 and $sCellValue1<30 then
$sCellValue = _ExcelReadCell($oExcel1, $i, 2)
$sfilepath = "C:\Users\Administrator\Desktop\temp\" & $sCellValue
;MsgBox(0, "", $sfilepath, 2)
$oExce2 = _ExcelBookNew(0)
_ExcelWriteCell($oExce2,"设备名称",1,1)
_ExcelWriteCell($oExce2,"计量单位",1,2)
_ExcelWriteCell($oExce2,"品牌型号",1,3)
_ExcelWriteCell($oExce2,"单价",1,4)
_ExcelWriteCell($oExce2,"保修期",1,5)
_ExcelWriteCell($oExce2,"使用年限",1,6)
_ExcelWriteCell($oExce2,"供应商",1,7)
_ExcelWriteCell($oExce2,"SN码",1,8)
_ExcelWriteCell($oExce2,"用途",1,9)
_ExcelWriteCell($oExce2,"备注",1,10)
_ExcelWriteCell($oExce2,"备注1",1,11)
for $a=1 to $sCellValue1;
_ExcelWriteCell($oExce2,$sCellValue,$a+1,1)
_ExcelWriteCell($oExce2,$sCellValue2,$a+1,2)
Next
_ExcelBookSaveAs($oExce2,$sfilepath,"xls")
_ExcelBookClose($oExce2,1)
EndIf
Next
_ExcelBookClose($oExcel1,0) ; 关闭退出
_ExcelBookSaveAs($oExce2,$sfilepath,"xls")
当含有变量的路径时,就会出错,如$sfilepath = "C:\Users\Administrator\Desktop\temp\" & $sCellValue
当含有变量的路径时,很正常,如$sfilepath = "C:\Users\Administrator\Desktop\temp\test" |