Bonjour à tous,

Voila je veux juste lire un fichier Word avec POI et par la suite récupérer certaines données.

Le pb c'est que j'arrive à lire tous le doc mais pas seulement les parties qui m'interessent.

Mon code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
import java.io.*;
import org.apache.poi.poifs.eventfilesystem.*;
import org.apache.poi.hdf.extractor.*;
 
 
public class PoiTest {
 
	public static void main(String[] args)
	throws IOException	{
 
		final String filename = args[0];
		POIFSReader r = new POIFSReader();
		r.read(new FileInputStream(filename));
		// create temp file of content
		String tempF="test.txtl";
		//
		testDoc td=new testDoc(filename, tempF);
		td.getText();
	}
 
} // end of class PoiTes
 
class testDoc {
	String origFileName;
	String tempFile;
	WordDocument wd;
 
	testDoc(String origFileName, String tempFile) {
	this.tempFile=tempFile;
	this.origFileName=origFileName;
	}
 
	public void getText() {
	try {
		wd = new WordDocument(origFileName);
		Writer out = new BufferedWriter(new FileWriter(tempFile));
		wd.writeAllText(out);
		out.flush();
		out.close();
	}
	catch (Exception eN) {
	System.out.println("Error reading document:"+origFileName+"\n"+eN.toString());
	}
	} // end for getText
 
} // end of class
merci d'avance

Répondez moi si vous voulez des informations plus claires