我正在尝试将 Excel 表格另存为 HTML 文件。 我准备了一个我想使用的包含我的样式的外部 CSS 文件。 但是,Excel 将表格保存为 HTML,其中包含多个样式选项,当它们以代码形式应用于特定元素时,会覆盖我的 CSS 文件。
有没有办法在没有样式元素的情况下从 Excel 中保存表格?
具体来说,我要删除的元素是“table-layout: fixed;”这阻碍了我控制表格宽度的尝试。
谢谢。
最佳答案
您可以使用一些 javascript 轻松地做到这一点,在网页中导入 html 文件,然后将其添加到您的脚本中,并在需要时添加它。
var e = document.getElementByTagName('table')[0]; //assuming the table is the 1st one to appear
// or get by id with document.getElementByID('IDhere')
e.removeAttribute("style");
或具有多个具有属性的表
var e = document.getElementByTagName('table');
for(var i = 0; i < e.length; i++) {
e[i].removeAttribute("style");
}
关于html - 将 Excel 表格保存为没有样式的 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40865022/