如何为Outlook邮件内的表格添加第二行法语表头且避免全表高亮
问题解决方案
异常原因
- HTML标签未正确闭合:新增法语表头行时如果漏写
</tr>、</th>标签,或者属性的双引号配对错误,会导致原有表头的bgcolor="#11ed69"属性作用范围溢出,覆盖整个表格 - 结构嵌套错误:如果直接把法语表头的单元格写在了原有表头的
<tr>标签内部,没有单独开新的<tr>行,也会触发样式异常
正确实现代码
strBeforeRows = "<head><style>table, th, td {border: 1px solid gray; border-collapse:" & _ "collapse;}</style></head><body>" & _ "<table style=""width:60%""><tr>" & _ "<th bgcolor=""#11ed69"">Rental Agreement # #</th>" & _ "<th bgcolor=""#11ed69"">Citation #</th>" & _ "<th bgcolor=""#11ed69"">Amount</th></tr>" & _ ' 新增法语表头行,不需要绿色背景可删除对应th的bgcolor属性 "<tr>" & _ "<th bgcolor=""#11ed69"">Numéro de contrat de location</th>" & _ "<th bgcolor=""#11ed69"">Numéro d'avis de contravention</th>" & _ "<th bgcolor=""#11ed69"">Montant</th></tr>"
注意事项
- Outlook的HTML解析规则比普通浏览器严格,所有标签必须严格成对闭合,属性引号必须完全配对,不要省略结束标签
- 法语表头的文字内容可以按需调整,不需要绿色背景直接删除对应
<th>标签里的bgcolor=""#11ed69"""属性即可
内容的提问来源于stack exchange,提问作者Shaves
相关产品推荐
相关产品推荐

