我用的是office word 2016版
創建文本對象
XWPFDocument docxDocument = new XWPFDocument();
創建段落對象
XWPFParagraph paragraphX = docxDocument.createParagraph();
//XWPFParagraph 段落屬性 //paragraphX.addRun(runX0);//似乎並沒有什么卵用 //paragraphX.removeRun(1);//按數組下標刪除run(文本) paragraphX.setAlignment(ParagraphAlignment.LEFT);//對齊方式 //paragraphX.setBorderBetween(Borders.LIGHTNING_1);//邊界 (但是我設置了好幾個值都沒有效果) //paragraphX.setFirstLineIndent(100);//首行縮進:-----效果不詳 //paragraphX.setFontAlignment(3);//字體對齊方式:1左對齊 2居中3右對齊 //paragraphX.setIndentationFirstLine(2);//首行縮進:-----效果不詳 //paragraphX.setIndentationHanging(1);//指定縮進,從父段落的第一行刪除,將第一行上的縮進移回到文本流方向的開頭。-----效果不詳 //paragraphX.setIndentationLeft(2);//-----效果不詳 //paragraphX.setIndentationRight(2);//-----效果不詳 //paragraphX.setIndentFromLeft(2);//-----效果不詳 //paragraphX.setIndentFromRight(2);//-----效果不詳 //paragraphX.setNumID(new BigInteger("3"));//設置段落編號-----有效果看不懂(僅僅是整段縮進4個字) //paragraphX.setPageBreak(true);//段前分頁 //paragraphX.setSpacingAfter(1);//指定文檔中此段最后一行以絕對單位添加的間距。-----效果不詳 //paragraphX.setSpacingBeforeLines(2);//指定在該行的第一行中添加行單位之前的間距-----效果不詳 //paragraphX.setStyle("標題 3");//段落樣式:需要結合addCustomHeadingStyle(docxDocument, "標題 3", 3)配合使用 paragraphX.setVerticalAlignment(TextAlignment.BOTTOM);//文本對齊方式(我猜在table里面會有比較明顯得到效果) paragraphX.setWordWrapped(true);//這個元素指定一個消費者是否應該突破拉丁語文本超過一行的文本范圍,打破單詞跨兩行(打破字符水平)或移動到以下行字(打破字級)-----(我沒看懂:填個false還報異常了)
