您好,我使用的组件的版本是23.6,我在使用html转word的时候,转出的word文件表格内文字的行间距和html的表格文字的行间距不一致,请问该如何处理?
以下是我的代码逻辑
String html = “ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <table width="100%" cellspacing="0" cellpadding="0" style="border: none;"> <tr class="firstRow"> <td width="329" valign="top" style="padding: 0px 7px; border: none;" > <p style="line-height: 8px;text-align: justify;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">甲 方:ka小薯条1715131232
<p style="line-height: 8px;text-align: justify;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">联系地址:1
<p style="line-height: 8px;text-align: justify;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">联系人:1
<p style="line-height: 8px;text-align: justify;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">联系电话:1
<p style="line-height: 8px;text-align: justify;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">电子邮件:1
<p style="line-height: 8px;text-align: justify;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">最终推广主体:ka小薯条1715131232
<td width="337" valign="top" style="padding: 0px 7px; border: none;" height="5"> <p style=";text-align: justify;line-height: 8px;font-size: 14px;font-family: 'Times New Roman', serif">
<span style="line-height: 8px;font-family: 宋体">乙 方:百度在线网络技术(北京)有限公司 <p style=";text-align: justify;line-height: 8px;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="font-family: 宋体;">联系地址:北京市海淀区上地十街10号
<p style=";text-align: justify;line-height: 8px;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">联系人:常家耀
<p style=";text-align: justify;line-height: 8px;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">联系电话:12345678901
<p style=";text-align: justify;line-height: 8px;font-size: 14px;font-family: 'Times New Roman', serif"> <span style="line-height: 8px;font-family: 宋体">电子邮件:xm-u1account-itp@123.com
”;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml(html);
Section section = doc.getFirstSection();
section.getPageSetup().setTopMargin(72.4);
section.getPageSetup().setRightMargin(53.9);
section.getPageSetup().setBottomMargin(72.4);
section.getPageSetup().setLeftMargin(53.9);
doc.save(outputStream, SaveFormat.DOCX);
实现效果如图所示:
1、html效果:
image.jpg (35.7 KB)
2、word效果:
image.jpg (91.7 KB)