html-docx-js-typescript
html-docx-js-typescript copied to clipboard
table表格导出后边框变成虚线了,怎么处理?
页面上table表格为实线,导出后在word里成虚线了,怎么处理?
Hi!
Before export for all tables add some properties: border = 1 style.borderCollapse = 'collapse'
F.E.:
const domParser = new DOMParser();
const htmlElement = domParser.parseFromString(html, 'text/html');
// add styles for tables by default
htmlElement.body.querySelectorAll('table').forEach(table => {
table.style.borderCollapse = table.style.borderCollapse || 'collapse';
table.border = table.border || '1';
});