_ExcelBookSaveAs保存问题
#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" 要看你的变量里是不是含有文件名中不允许出现的特殊字符,最好用consolewrite显示一下看看 变量里的值我是从exec上读出来的,我看了一下,没有特殊字符啊 文件传上来看一下 我曾经碰到过~我实现的方法为 _ExcelBookClose($oExce2,1)
这个就直接保存了,那个save就没有必要,如果你要保存到其他地方,那么就移动文件或者复制文件~ 恩,来学习学习哈 建议采用新版,稳定版3.3.12 。0
页:
[1]