如何使用 DocxJS 删除 table 边框?
How can I remove table borders with DocxJS?
假设我想删除此 table:
中的所有边框
---------------------------
| image | text |
---------------------------
按照在线文档:https://docx.js.org/#/usage/tables
new Table({
borders: {
top: {style: BorderStyle.NONE},
bottom: {style: BorderStyle.NONE},
left: {style: BorderStyle.NONE},
right: {style: BorderStyle.NONE},
},
rows: [
new TableRow({
children: [
new TableCell({
children: [
new Paragraph({ children: [some_image_file] }),
],
}),
new TableCell({
children: [
new Paragraph({ text: "text" }),
],
}),
],
}),
],
})
这给出:
image | text
根据文档,在 TableCell
内移动边框选项应该会影响单元格的边框,但我这样做时看不到任何结果。有什么想法可以实现 table 没有任何边界吗?
如@cbloss793 所述,TableCell
的边框选项似乎还必须包含 size: 0
属性以删除相应的边框。为了安全起见,我还添加了 color: "FFFFFF"
。
...
new TableCell({
borders: {
top: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
bottom: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
left: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
right: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
},
...
假设我想删除此 table:
中的所有边框---------------------------
| image | text |
---------------------------
按照在线文档:https://docx.js.org/#/usage/tables
new Table({
borders: {
top: {style: BorderStyle.NONE},
bottom: {style: BorderStyle.NONE},
left: {style: BorderStyle.NONE},
right: {style: BorderStyle.NONE},
},
rows: [
new TableRow({
children: [
new TableCell({
children: [
new Paragraph({ children: [some_image_file] }),
],
}),
new TableCell({
children: [
new Paragraph({ text: "text" }),
],
}),
],
}),
],
})
这给出:
image | text
根据文档,在 TableCell
内移动边框选项应该会影响单元格的边框,但我这样做时看不到任何结果。有什么想法可以实现 table 没有任何边界吗?
如@cbloss793 所述,TableCell
的边框选项似乎还必须包含 size: 0
属性以删除相应的边框。为了安全起见,我还添加了 color: "FFFFFF"
。
...
new TableCell({
borders: {
top: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
bottom: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
left: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
right: {style: BorderStyle.NONE, size: 0, color: "FFFFFF"},
},
...