问题描述
我正在尝试在使用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 (将#修改为@)