Apache POI Word
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
table, text, enter, etc. How do I get rid of gaps in everything?
I want to do it like 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)
Resulting .docx
file was opened with LibreOffice 7.0.4.2 to get the above screenshot.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.