html-docx-js-typescript icon indicating copy to clipboard operation
html-docx-js-typescript copied to clipboard

table表格导出后边框变成虚线了,怎么处理?

Open kdhgyc opened this issue 5 years ago • 1 comments

页面上table表格为实线,导出后在word里成虚线了,怎么处理?

kdhgyc avatar Jul 06 '20 08:07 kdhgyc

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';
  });

sleitor avatar Apr 19 '22 11:04 sleitor