Bonjour tout le monde,
Après de nombreuses recherche sur le net, je viens chercher de l'aide dans les forums.
En fait, j'ai crée un programme de prise de notes de livres. J'ai des livres qui ont plusieurs notes. Je veux exporter les livres au format word.
Pour chaque note, qui prend un paragraphe, je veux ajouter une note de bas de page. Mais voilà apparement pour créer un footnote il me faut un objet de type CTFtnEdn que je ne connais pas du tout (du package org.openxmlformats.schemas.wordprocessingml.x2006.main).
Je vous donnes mon code :
public void actionPerformed(ActionEvent e){
try{
XWPFDocument doc = new XWPFDocument();
// Titre
XWPFParagraph p1 = doc.createParagraph(); // création du premier paragraphe qui sera le titre
p1.setAlignment(ParagraphAlignment.CENTER);
// titre du livre
XWPFRun r1 = p1.createRun();
r1.setText("<< "+livre.getTitre()+" >>");
r1.addCarriageReturn();
r1.setFontSize(20);
r1.setFontFamily("Times New Roman");
// auteur du livre
XWPFRun r2 = p1.createRun();
r2.setText(livre.getAuteurs().get(0));
r2.setBold(true);
r2.addCarriageReturn();
r2.setFontFamily("Times New Roman");
r2.setFontSize(14);
// edition + lieu + date du livre
XWPFRun r3 = p1.createRun();
r3.setText("("+livre.getEdition()+", "+livre.getLieu()+", "+livre.getDate()+")");
r3.setFontFamily("Times New Roman");
r3.setFontSize(12);
r3.addCarriageReturn();
// Corps
int i;
// pour chaque note je crée un nouveau paragraphe
for(i=0;i<livre.getNotes().size();i++){
XWPFParagraph p2 = doc.createParagraph();
p2.setAlignment(ParagraphAlignment.LEFT);
XWPFRun r = p2.createRun();
r.setText("<< "+livre.getNotes().get(i).getExtrait()+" >>");
r.setFontFamily("Times New Roman");
r.setFontSize(10);
// MON PROBLEME SE SITUE ICI. JE VEUX CREE DONC UN FOOTNOTE MAIS LE CONSTRUCTEUR PREND EN PARAMETRE UN CTFtnEdn ET APPAREMENT IL NE S'INSTANCIE PAS. COMMENT RECUPERER MON OBJET DE TYPE CTFtnEdn ?
XWPFFootnote fn = new XWPFFootnote(doc,new CTFtnEdn());
}
// création du document word (.docx)
FileOutputStream out = new FileOutputStream("exports/"+livre.getAuteurs().get(1)+" - "+livre.getTitre()+".docx");
doc.write(out);
out.close();
}
catch(FileNotFoundException ex){
}
catch(IOException ex){
}
}
MERCI PAR AVANCE DE VOTRE AIDE
Partager