I am trying to read a Microsoft Word file via Java. I have included all .jar files from Apache PoE-3.8-Beta 1 in my cell path. I after my code is: I am using an XWPF word extractor because I am trying to read a document of 2007 word, but for some reason I have found the right POI I am unable to work on it. Any help is greatly appreciated thanks in advance! ~ Woods remove the line, org.apache.poi.poifs.filesystem.OfficeXmlFileException: appears in the supply data office 2007+ XML But, when I try this ongoing, I get the following exception. You are calling part of the POI that is related to OLE2 office documents. At org.apache.poi (HeaderBlock.java:131) ;. Init & gt; You need to call a separate part of POI to process this data at org.apache.poi.poifs.storage.HeaderBlock (instead of XSSF instead of HSSF) .poifs.storage.HeaderBlock. & Lt; Init & gt; (HeaderBlock.java:104) on org.apache.poi.poifs.filesystem.POIFSFileSystem. & Lt; Init & gt; (POIFSFileSystem.java:138) on readingmsword07.Main.main (Main Java: 27)
import org.apache .poi.xwpf.extractor.XWPFWordExtractor; Import java.io.file; Import java.io.FileInputStream; Import java.io.IOException; Import java.io.InputStream; Import java.io * *; Import org.apache.poi.poifs.filesystem.POIFSFileSystem; Import org.apache.poi.xwpf.usermodel.XWPF document; Public class main {public static void (String [] args) {FileInputStream Financial Institutions = New FileInputStream try {("C: \\ TrialDoc.docx"); POIFSFile system filesystem = new POIFSFileSystem (fis); Org.apache.poi.xwpf.extractor.XWPFWordExtractor oleTextExtractor = New XWPFWordExtractor (New XWPFDocument (Financial Institutions)); System.out.print (oleTextExtractor.getText ()); } Hold (exception e) {e.printStackTrace (); }}}
< Code> POIFSFile system filesystem = new POIFSFileSystem (fis);
Comments
Post a Comment