将Excel工作表另存为HTML

编程入门 行业动态 更新时间:2024-10-27 01:25:00
本文介绍了将Excel工作表另存为HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I'm attempting to save each sheet in a workbook (foo,bar,baz) as a separate HTML document (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

结果:

  • Output 中每个工作表(名为<工作表名称> _files )的文件夹,其中包含每个工作表的HTML文档(命名为 sheet< n> .html ),以及一些其他文件( filelist.xml , stylesheet.css , tabstrip.html )

  • a folder in Output for each sheet (named <sheet name>_files) that contains an HTML document for each sheet (named sheet<n>.html), plus a few additional files (filelist.xml,stylesheet.css,tabstrip.html)

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

a file in Output for each sheet (named .html`) that references the corresponding folder

我该如何纠正?

推荐答案

此脚本:

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.xml , stylesheet.css , tabstrip.html )
  • a file named data.HTML
  • a folder named data_files, containing a document for each sheet (sheet<NNN>.HTML), plus additional files (filelist.xml,stylesheet.css,tabstrip.html)

更多推荐

将Excel工作表另存为HTML

本文发布于:2023-10-26 11:43:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1530034.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:另存为   工作   Excel   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!