[英]Apache POI Word Styles How do I get rid of gaps?
Apache POI Word Apache 兴趣点字
table, text, enter, etc. How do I get rid of gaps in everything?表格、文本、输入等。如何消除所有内容中的空白?
Can I do it like no spacing in word style?我可以像在文字样式中没有间距那样做吗?
Apache POI Word Apache 兴趣点字
table, text, enter, etc. How do I get rid of gaps in everything?表格、文本、输入等。如何消除所有内容中的空白?
I want to do it like TO我想像 TO 那样做
public class PoiTest {
public static void main(String[] args) throws IOException {
XWPFDocument doc = new XWPFDocument();
XWPFTable table = doc.createTable();
XWPFTableRow row1 = table.getRow(0);
row1.getCell(0).setText("First Row, First Column");
row1.addNewTableCell().setText("First Row, Second Column");
row1 = table.createRow();
row1.getCell(0).setText("Second Row, First Column");
row1.getCell(1).setText("Second Row, Second Column");
row1 = table.createRow();
row1.getCell(0).setText("Third Row, First Column");
row1.getCell(1).setText("Third Row, Second Column");
XWPFParagraph title = doc.createParagraph();
XWPFRun titleRun = title.createRun();
titleRun.setText("First");
title = doc.createParagraph();
titleRun = title.createRun();
titleRun.setText("Second");
FileOutputStream out;
try {
out = new FileOutputStream("c:\\test\\test.docx");
doc.write(out);
System.out.println("ok!!!");
if (out != null) {
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
Bad news (or... possibly good news).坏消息(或者……可能是好消息)。 When running your code as-is, it looks just fine:按原样运行代码时,它看起来很好:
Inside the running code, the result of System.getProperty("java.version")
is 11.0.16
(although Eclipse claims I am using OpenJDK 17.0.4)在运行代码中, System.getProperty("java.version")
的结果是11.0.16
(尽管 Eclipse 声称我使用的是 OpenJDK 17.0.4)
Resulting .docx
file was opened with LibreOffice 7.0.4.2 to get the above screenshot.使用 LibreOffice 7.0.4.2 打开生成的.docx
文件以获得上述屏幕截图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.