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
| generer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
XWPFDocument document = new XWPFDocument();
FileOutputStream out = new FileOutputStream(new File("montestapache.docx"));
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText("Mon test pour voir si cela fonctionne " +
"Et ca serait cool que OUI cela me génére un Document Word ");
document.write(out);
out.close();
System.out.println("montestapache.docx généré avec succès");
Toast.makeText(MainActivity.this, "Document crée avec Succès", Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(MainActivity.this, "Erreur ! Opération annulée", Toast.LENGTH_SHORT).show();
}
}
}); |
Partager