将Excel工作表保存为HTML

我试图将工作簿( foobarbaz )中的每个工作表保存为一个单独的HTML文档( foo.htmlbar.htmlbaz.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 

结果如下:

  • 每个工作表的Output文件夹(命名为<sheet name>_files文件),其中包含每个工作表的HTML文档(名为工作sheet<n>.html ),以及一些附加文件( filelist.xmlstylesheet.csstabstrip.html

  • Output中的每个表格(命名为.html`)的文件引用相应的文件夹

我该如何纠正?

这个脚本:

 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<NNN>.HTML ),以及其他文件( filelist.xmlstylesheet.csstabstrip.html