【问题标题】:Width 100% for 2 html tables is not working in .xls file2 个 html 表格的 100% 宽度在 .xls 文件中不起作用
【发布时间】:2014-04-01 21:23:59
【问题描述】:

我正在尝试打开一个包含所有 html 内容的 .xls 文件。 在 html 内容中,我试图包含 2 个宽度为 100% 的表格(电子表格的视口宽度)。

如果我只包含第一个表,则 WIDTH=100% 有效。但是当我包含第二张桌子时,两个桌子的宽度似乎都是自动的,而不是只适用于 1 张桌子的宽度。

以下是 .xls 文件的内容:

<HTML>
<HEAD>
    <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="application/vnd.ms-excel; charset=UTF-8">
<TITLE>Open in Excel as well as browser (this is ignored by Excel)</TITLE>
</HEAD>
<BODY>
    <H2>Useful HTML tags understood by Excel</H2>
    <BLOCKQUOTE>The list given below is not an exhastive list of all tags understood by Excel.
    Where there are several codes that achieve the same effect, I
    have only included one of them.</BLOCKQUOTE>

    <TABLE BORDER=YES WIDTH=100%>
    <TR>
        <TH WIDTH=20%><B>Tag</B></TD>
        <TH WIDTH=30%><B>Valid Attributes</B></TD>
        <TH WIDTH=50%><B>Excel interpretation</B></TD>
    </TR>
    <TR>
        <TD>TD</TD>
        <TD>BGCOLOR=colour</TD>
        <TD BGCOLOR=YELLOW>Background colour for the cell</TD>
    </TR>
    <TR>
        <TD>B</TD>
        <TD ALIGN=CENTER>-</TD>
        <TD><B>Bold</B></TD>
    </TR>
    <TR>
        <TD>TD, TH</TD>
        <TD>ROWFIELD</TD>
        <TD>Pivot table: Type of pivot table</TD>
    </TR>
    </TABLE>
    <BR/><BR/><BR/>
    <TABLE BORDER=YES WIDTH=100%>
    <TR>
        <TH WIDTH=20%><B>Tag</B></TD>
        <TH WIDTH=30%><B>Valid Attributes</B></TD>
        <TH WIDTH=50%><B>Excel interpretation</B></TD>
    </TR>
    <TR>
        <TD>TABLE</TD>
        <TD>ALIGN=LEFT|RIGHT|CENTER|JUSTIFY</TD>
        <TD>Table and its placement</TD>
    </TR>
    <TR>
        <TD>TABLE</TD>
        <TD>WIDTH=nn</TD>
        <TD>Size of entire table</TD>
    </TR>
    <TR>
        <TD>TABLE</TD>
        <TD>CROSSTABGRAND=NONE|ROW|COLUMN|ROWCOLUMN</TD>
        <TD>Pivot table: where grand totals to be placed</TD>
    </TR>
    <TR>
        <TD>TD, TH</TD>
        <TD>ROWFIELD</TD>
        <TD>Pivot table: Type of pivot table</TD>
    </TR>
    </TABLE>
</BODY>
</HTML>

要明确,我的要求是我需要渲染 2 个 html 表格,宽度均为 100%。

如果您有任何疑问,请发表评论。

【问题讨论】:

    标签: html excel html-table


    【解决方案1】:

    将它们放入主表中。

    <TABLE WIDTH=100%><TR><TD>
    
        <TABLE.......
    
    </TD></TR>
    <TR><TD>
    
        <TABLE......
    
    </TD></TR></TABLE>
    

    【讨论】:

    • 这行得通。感谢您的想法,但我试图在不更改已经有 2 个单独表格的现有 html 结构的情况下修复它。我希望通过更改一些 html 属性或一些 css 来修复。有什么想法吗?
    • 我猜当你放置几个单独的表时,excel 将它们视为列,所以我不知道你该怎么做。
    猜你喜欢
    • 2014-10-27
    • 2012-06-27
    • 2013-11-17
    • 1970-01-01
    • 2019-03-08
    • 2014-05-14
    • 1970-01-01
    • 2012-01-01
    • 1970-01-01
    相关资源
    最近更新 更多