如何从java中生成的.docx文件中获取行数?
/* 这是我的密码。如何从java中生成的.docx文件中获取行数?,java,apache-poi,docx,Java,Apache Poi,Docx,/* 这是我的密码。 它在手动创建的word文档中运行良好,但在使用XWPFDOcument类的生成word文档(Lineounter.docx)中不起作用。查看前面给出的解决方案:-您使用的是哪一版本的poi jar?poi-3.7.jar@Prasath Bala public static void Worddoc(String Finalcombined) { String exampleString = "மதுரையில் நடந்த கலைவிழாவுக்கு
它在手动创建的word文档中运行良好,但在使用XWPFDOcument类的生成word文档(Lineounter.docx)中不起作用。查看前面给出的解决方案:-您使用的是哪一版本的poi jar?poi-3.7.jar@Prasath Bala
public static void Worddoc(String Finalcombined) {
String exampleString = "மதுரையில் நடந்த கலைவிழாவுக்கு மந்திரி சுப்பிரமணியம் தலைமை வகித்துப்பேசினார் அவர் கூறியதாவது";
//Blank Document
XWPFDocument document = new XWPFDocument();
//Write the Document in file system
FileOutputStream out = null;
FileOutputStream outodt = null;
try {
out = new FileOutputStream(new File("LineCounter.docx"));
} catch (FileNotFoundException ex) {
Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, "Error --> " + ex.toString());
}
try {
XWPFParagraph paragraph = document.createParagraph();
schemasMicrosoftComOfficeWord.CTWrap.Factory.parse("Latha")
);
run.setFontFamily("Latha");
run.getCTR().getRPr().getRFonts().setHAnsi("Latha");
run.setFontSize(10);
run.setText(exampleString);
document.write(out);
} catch (IOException ex) {
Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
}
try {
out.close();
} catch (IOException ex) {
Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
}
XWPFDocument doc = new XWPFDocument(POIXMLDocument.openPackage(lowerFilePath));
int i = doc.getProperties().getExtendedProperties().getUnderlyingProperties()..getLines();
System.out.println("i" + i);
System.out.println("PageCounter.docx written successully");
}