使用多个表头打印HTML表

时间:2018-06-15 03:43:47

标签: html html-table

请帮助我,如何使用多个表头打印HTML表格? 我的表格标题的示例代码如下:

<table>
    <thead>
        <tr>
            <th colspan="6">January 2018</th> 
        </tr>
        <tr>
            <th colspan="2">TARGET</th>
            <th colspan="2">ORDERED</th>
            <th colspan="2">SALES</th>
        </tr>
        <tr>
            <th>QTY</th> <th>AMOUNT</th>
            <th>QTY</th> <th>AMOUNT</th>

            <th>QTY</th> <th>AMOUNT</th>
            <th>QTY</th> <th>AMOUNT</th>

            <th>QTY</th> <th>AMOUNT</th>
            <th>QTY</th> <th>AMOUNT</th>
        </tr>
    </thead>

    <tbody>

    </tbody>
</table>

这就是我想在Table Header的可打印页面中看到的内容:

2 个答案:

答案 0 :(得分:0)

见下面的代码..

<table border="2" >
<thead>
    <tr>
        <th colspan="6" ></th>
        <th colspan="6">January 2018</th> 
    </tr>
    <tr>
        <th colspan="6"></th>
        <th colspan="2">TARGET</th>
        <th colspan="2">ORDERED</th>
        <th colspan="2">SALES</th>
    </tr>
    <tr>

    </tr>
    <tr>
        <th  colspan="2">item</th>
        <th colspan="4">Description</th>
        <th colspan="1">QTY</th> <th colspan="1">AMOUNT</th>
        <th colspan="1">QTY</th> <th colspan="1">AMOUNT</th>
        <th colspan="1">QTY</th> <th colspan="1">AMOUNT</th>
    </tr>
</thead>

<tbody>

</tbody>

这是工作示例:: https://jsfiddle.net/deepakvaishnav/0L48mvcz/

答案 1 :(得分:0)

<table border="2" >
<thead>
    <tr>
        <th colspan="2"></th>
        <th colspan="6" ></th>
        <th colspan="6">January 2018</th> 
    </tr>    
    <tr>
        <th colspan="2"></th>
        <th colspan="6"></th>
        <th colspan="2">TARGET</th>
        <th colspan="2">ORDERED</th>
        <th colspan="2">SALES</th>
    </tr>
    
    <tr>
        <th  colspan="2">item</th>
        <th colspan="6">Description</th>
        <th colspan="1">QTY</th> <th colspan="1">AMOUNT</th>
        <th colspan="1">QTY</th> <th colspan="1">AMOUNT</th>
        <th colspan="1">QTY</th> <th colspan="1">AMOUNT</th>
    </tr>
</thead>

<tbody>

</tbody>