java用poi实现对word读取和修改操作

 

 

	// TODO Auto-generated method stub
		org.apache.poi.hwpf.extractor.WordExtractor doc = null;
		try {
			doc = new WordExtractor(new FileInputStream("D:\\del\\test.doc"));
			String[] comments = doc. getCommentsText(); 
			System.out.println(comments[0]);
			int pages = doc.getSummaryInformation().getPageCount();//总页数 
			int wordCount = doc.getSummaryInformation().getWordCount();//总字符数
			
			System.out.println(pages);
			System.out.println(wordCount);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		//提取.doc正文文本 
		String text = doc.getText();
		
		System.out.println(text);
		

 

 

 

http://www.laokboke.net/2011/10/29/java-poi-word/

你可能感兴趣的:(Jave,SE)