如何解决使用apache-poi,如何在同一Word文档中创建一个不对齐的段落和另一个带有悬挂缩进的段落?
我正在尝试在使用apache-poi创建的word文档中创建多个段落。第一段没有对齐,只是换行到下一行。第二段具有悬挂缩进设置。当我运行我的应用程序时,这两段的输出都具有悬挂缩进效果。如何获得一个段落具有悬挂缩进的设置,而另一个则没有?
以下是一些示例代码:
XWPFDocument document = new XWPFDocument();
FileOutputStream out = new FileOutputStream( new File("C:\\TEMP\\createdocument.docx"));
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setBold(true);
run.setColor("0000ff");
run.setFontFamily("Times New Roman");
run.setFontSize(12);
run.setText("2. ");
run = paragraph.createRun();
run.setBold(true);
run.setItalic(true);
run.setColor("0000ff");
run.setFontFamily("Times New Roman");
run.setFontSize(12);
run.setText("Ferrule,optical fiber connector,stainless steel Fiberguide Industries 708-110: ");
run = paragraph.createRun();
run.setColor("0000ff");
run.setFontFamily("Times New Roman");
run.setFontSize(12);
run.setText("These ferrules are made of type 303 austenitic stainless steel. Gross clean,(ultrasonic detergent cleaning) and then precision clean (precision ultrasonic detergent cleaning) or (precision wiping).");
run.addBreak();
//Start of paragraph 2
XWPFParagraph paragraph1 = document.createParagraph();
XWPFRun run1 = paragraph1.createRun();
paragraph1.setIndentationHanging(345);
run1.setBold(true);
run1.setColor("0000ff");
run1.setFontFamily("Times New Roman");
run1.setFontSize(12);
run1.setText("1. ");
run1.setBold(true);
run1.setItalic(true);
run1.setColor("0000ff");
run1.setFontFamily("Times New Roman");
run1.setFontSize(12);
run1.setText("Ferrule,stainless steel Fiberguide Industries 708-110: ");
run1 = paragraph1.createRun();
run1.setColor("0000ff");
run1.setFontFamily("Times New Roman");
run1.setFontSize(12);
run1.setText("These ferrules are made of type 303 austenitic stainless steel. Gross clean,(ultrasonic detergent cleaning) and then precision clean (precision ultrasonic detergent cleaning) or P-IX (precision wiping).");
run1.addBreak();
document.write(out);
out.close();
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。