1 pièce(s) jointe(s)
[POI] Problème de formule avec Apache POI
Bonjour ,
je cherche à appliquer une formule "VLOOKUP" dans une cellule d'un fichier excel avec :
Valeur à chercher : I9 dans fichier excel fsGRET
Plage de recheche : dans le fichier excel fsREMP
Resultat à mettre dans une cellule du fichier fsGRET
Voilà le code que je test:
Code:
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 48 49 50 51 52
| String ChemREMP = "C:\\Documents and Settings\\Bureau\\Remplissage_2015_2.xls";
File fXLS = new File(ChemREMP);
if (fXLS.exists()){
String ChemGRET = "C:\\Documents and Settings\\Bureau\\GRET\\2015\\N_GRET_REMP.xls";
File fGRET = new File(ChemGRET);
if (fGRET.exists()){
// OUVRIR FICHIER REMPLISSAGE
try {
POIFSFileSystem fsREMP = new POIFSFileSystem(new FileInputStream(ChemREMP));
HSSFWorkbook wbREMP = new HSSFWorkbook(fsREMP);
//OUVRIR FICHIER GRET
try {
POIFSFileSystem fsGRET = new POIFSFileSystem(new FileInputStream(ChemGRET));
HSSFWorkbook wbGRET = new HSSFWorkbook(fsGRET);
HSSFSheet feuilGRET = wbGRET.getSheet("Elément");
HSSFRow rowGRET = feuilGRET.getRow(8);
rowGRET.createCell(23,HSSFCell.CELL_TYPE_FORMULA).setCellFormula("VLOOKUP(I9,'C:\\Documents and Settings\\Bureau\\[Remplissage_2015_2.xls]FR'!$B$2:$Q$101,15,FALSE)");
FileOutputStream fileOutGRET = new FileOutputStream(ChemGRET);
wbGRET.write(fileOutGRET);
fileOutGRET.close();}
catch (FileNotFoundException e) {
e.printStackTrace();}
catch (IOException e) {
e.printStackTrace();}
FileOutputStream fileOutXLS = new FileOutputStream(ChemREMP);
wbREMP.write(fileOutXLS);
fileOutXLS.close();}
catch (FileNotFoundException e) {
e.printStackTrace();}
catch (IOException e) {
e.printStackTrace();}
else {
ntinfo = 2;
fin(ntinfo,Anec,Perec,Sem,Angret,tInfo);}}
else {
ntinfo = 1;
fin(ntinfo,Anec,Perec,Sem,Angret,tInfo);}
}});
} |
Le résultat dans la cellule est : VLOOKUP(I9;#REF!$B$2:$Q$101;15;FAUX)
J'utilise
Eclipse
Apache POI 3.13
Et je précise que je suis débutant .....
Merci d'avance de votre aide