2014-11-29 3 views
0
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.IOException; 
import org.apache.poi.hwpf.HWPFDocument; 
import org.apache.poi.hwpf.extractor.WordExtractor; 
import org.apache.poi.poifs.filesystem.OfficeXmlFileException; 
import org.apache.poi.poifs.filesystem.POIFSFileSystem; 

public class Init { 

public static void main (String[] argc) throws IOException { 
    HWPFDocument myWorkBook = new HWPFDocument(
     new POIFSFileSystem(
      new FileInputStream("/home/jashka/Лаби/6.docx"))); 

    System.out.println(myWorkBook.getDocumentSummaryInformation()); 
    } 
} 

Сообщение об ошибке:Получить сводный документ информацию из документа Word,

Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException: 
The supplied data appears to be in the Office 2007+ XML. You are calling the part 
of POI that deals with OLE2 Office Documents. You need to call a different part of POI 
to process this data (eg XSSF instead of HSSF) 
+0

Мне нужно знать количество страниц в документе Word –

ответ

2

Используйте XWPFDocument вместо HWPFDocument.

Смежные вопросы