我正在使用 Qtextdocument 生成报告,我已经以编程方式准备了一个表格字符串作为 html 字符串,但是当我渲染它时,没有显示边框(图 2)
这是字符串示例:
<html>
<head>
<style>
table, th, td { white-space: nowrap; border: 1px solid black; border-collapse: collapse; padding: 2px 4px; text-align: center;}
</style>
</head>
<body>
<table width="100%">
<colgroup span="2" style="border: 2px solid black;">
<colgroup span="7" style="border: 2px solid black;">
<colgroup span="7" style="border: 2px solid black;">
<colgroup span="9" style="border: 2px solid black;">
<colgroup span="8" style="border: 2px solid black;">
<colgroup span="1" style="border: 2px solid black;">
<tr>
<td colspan="2" > <img src="Log1.png" width="192" height="86"/></td>
<td colspan="31" > Title line1<br/>line2</td>
<td> <img src="Log2.png" width="86" height="86" /> </td>
</tr>
<tr>
<td>Month:</td><td>june-19</td><td>01</td><td>02</td><td>03</td><td>04</td><td>05</td><td>06</td><td>07</td><td>08</td><td>09</td><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td><td>30</td><td>31</td><td>Total</td>
</tr>
<tr>
<td colspan="2">col span 2</td><td colspan="7">col span 7</td><td colspan="7">col span 7</td><td colspan="9">col span 9</td><td colspan="8">col span 8</td>
</tr>
<tr style="border:2px solid black;">
<td colspan="34">long line sub title</td>
</tr>
<tr>
<td rowspan="3">item1</td>
<td>item1.1</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td></td><td></td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>29</td>
<tr>
<td>item1.2</td><td></td><td></td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>29</td>
</tr>
<tr style="border-bottom:2px solid black;">
<td>item1.3</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>31</td>
</tr>
<tr>
<td rowspan="2">item2</td>
<td>item2.1</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>31</td>
<tr style="border-bottom:2px solid black;">
<td>item2.2</td><td>X</td><td></td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td></td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td></td><td>28</td>
</tr>
<tr>
<td> item3</td>
<td>item3.1</td><td>X</td><td>X</td><td>X</td><td>X</td><td></td><td></td><td></td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>X</td><td>28</td>
</tr>
</table>
</body>
</html>