html - 将 Excel 表格保存为没有样式的 html

标签 html css excel tablelayout

我正在尝试将 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/

相关文章:

JavaScript 良好实践 : remove inline onsubmit(), 全局变量

php - 创建新页面时,不考虑 css

Excel - 从另一个 xls 文件读取数据而不复制内容

excel - 批量强制关闭所有excel文件

html - wordpress 中的代码无法运行,尽管它可以在其他平台上运行

html - CSS 高度 % 和 Px

html - 来自网络的图像不显示

css "::after"类在 Internet Explorer 中不起作用

javascript - 使 fadetoggle 淡入

python - 如果某个单元格包含带有python的 "0",有没有办法在excel中删除一行?