bonjour à tous
je cherche à afficher le contenu d'un fichier texte dans mon report en utilisant les "eventhandler" mais j'arrive pas à relier la classe java avec le report à traves la méthode onprepare.Si quelqu'un a une idée.
voici le code de mon classe java:je vous remercie
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 import java.io.*; import org.eclipse.birt.report.engine.api.script.eventadapter.TextItemEventAdapter; import org.eclipse.birt.report.engine.api.script.element.ITextItem; import org.eclipse.birt.report.engine.api.script.IReportContext; public class FileRead extends TextItemEventAdapter { public void onPrepare( ITextItem TextItem, IReportContext reportContext ) { try { FileInputStream fstream = new FileInputStream("D:\\adresse.txt"); // Get the object of DataInputStream DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; String content=""; //Read File Line By Line while ((strLine = br.readLine()) != null) { // Print the content on the console content = content + strLine + "\n"; } //Close the input stream in.close(); TextItem.setContent(content); } catch (Exception e ) { e.printStackTrace( ); } } }
Partager