使用Applescript来生成和写入一个Excel文件

新的AppleScript,但我正在处理一个脚本,获取图像的文件夹,获取名称,颜色configuration文件,宽度,高度,并计算每个图像的宽高比(WxH),并将所有信息导出到Excel文件。 我能够成功地做到这一点,当简单地写入一个.csv,但现在我真的想写一个.xls,所以我也可以做一些条件格式的纵横比列。 下面是造成麻烦的代码块。 当我去编译时,我得到以下错误:

AppleScript编译错误

无法将«class ccel»的«class DPVu»设置为“A”#num到imgName。 访问不允许。

此错误发生在第一个“单元格的设置值”语句。 如果我每次对这些行进行注释并编译,则会为每个行引发相同的错误。

我已经尝试了谷歌search的一切,我可以想到的谷歌,并没有发现什么有用的…

码:

--counter variable for excel row placement. (row 1 is a header row) set num to 2 repeat with img in imgFolder --write specs to excel file tell application "Microsoft Excel" set value of Cell "A"&num to imgName set value of Cell "B"&num to imgColorProfile set value of Cell "C"&num to imgWidth set value of Cell "D"&num to imgHeight set value of Cell "E"&num to imgRatio end tell --incremental counter for next excel row set num to num + 1 end repeat 

我会写得更简单

 set num to 2 repeat with img in imgFolder --write specs to excel file tell application "Microsoft Excel" tell row num set value of cell 1 to imgName set value of cell 2 to imgColorProfile set value of cell 3 to imgWidth set value of cell 4 to imgHeight set value of cell 5 to imgRatio end tell end tell --incremental counter for next excel row set num to num + 1 end repeat