使用Applescript从Excel导出XLS文件为HTML

时间:2017-06-02 17:12:31

标签: excel applescript

我正在尝试将Excel文档(所有工作表)导出为HTML。当使用下面的代码时,我没有收到错误,脚本运行了几秒钟(大约15秒),但实际上从未产生任何输出。我尝试用HFS和POSIX格式的完整路径替换文件名“test.html”,我仍然得到相同的结果 - 没有

    tell application "Microsoft Excel"
        tell active workbook
            save as sheets filename "test.html" file format HTML file format -- doesn't seem to actually work
        end tell
    end tell

如果有人能够看到我的错误和/或过去成功地使用此功能,我会很乐意解释我的问题。

提前致谢。

1 个答案:

答案 0 :(得分:0)

这两个对我有用:

tell application "Microsoft Excel"
    tell active workbook
        save as active sheet filename (POSIX file "...full path here..." as text) file format HTML file format
    end tell
end tell


tell application "Microsoft Excel"
    tell active workbook
        save as active sheet filename "...full path here..." file format HTML file format
    end tell
end tell

(虽然我希望它只是导出活动工作表,但它实际上会转储工作簿中的所有工作表。)