将 Excel 个工作表另存为 HTML

Save Excel sheets as HTML

我正在尝试将工作簿(foobarbaz)中的每个 sheet 保存为单独的 HTML 文档(foo.html,bar.html,baz.html):

set theDirectory to (path to desktop as text) & "Output:"

set theSource to choose file with prompt "Choose file:" default location "/Users/<user>/Desktop/" of type {"XLS", "XLSX"}

tell application "Microsoft Excel"

    activate

    set theWorkbook to open theSource

    set theSheets to every sheet of active workbook

    repeat with theSheet in theSheets

        set theDestination to theDirectory & (the name of theSheet) & ".html"
        log theDestination

        tell theSheet
            save as sheet filename theDestination file format HTML file format
        end tell

    end repeat

    quit saving no

end tell

结果:

我该如何纠正?

这个脚本:

set theSource to choose file with prompt "Choose file:" default location (path to desktop) of type {"XLS", "XLSX"}
set theDestination to (choose folder with prompt "Choose destination folder:" default location path to desktop)
set thePath to (theDestination as text) & "data.HTML"

tell application "Microsoft Excel"
    activate
    open theSource
    tell active workbook
        save as active sheet filename thePath file format HTML file format
    end tell
    quit saving no
end tell

将生成:

  • 一个名为 data.HTML
  • 的文件
  • 一个名为 data_files 的文件夹,其中包含每个 sheet(sheet<NNN>.HTML)的文档,以及其他文件(filelist.xmlstylesheet.csstabstrip.html)