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
| public void controle(File fichier,int nbcell,HSSFSheet sheetEntree) throws FileNotFoundException, IOException{
InputStream fp=new FileInputStream(fichier);
int lastcellEnt=0;
try{
HSSFWorkbook wbEntree=new HSSFWorkbook(fp);
sheetEntree=(HSSFSheet) wbEntree.getSheetAt(0);
HSSFRow row=null;
HSSFCell cell=null;
//int lastcellnum=0;
for(int i=0;i<sheetEntree.getLastRowNum();i++){
row=sheetEntree.getRow(13);
//si la condition est vérifier à donc au moins une cellule non vide
if(row !=null){
lastcellEnt=row.getLastCellNum();
for(int j=1;j<lastcellEnt;j++){
//récuperer la cellule puis sa valeur
cell=row.getCell(j);
// appelle la methode et celle ci lui affecte le bon typage
if (cell != null) {
nbcell=row.getLastCellNum();
if(nbcell!=30){
creeFichier(wbEntree, fichier, erreur);
}else{
saveTo1(wbEntree, fichier);
}
}
}
}
}
}
finally{
fermerLeFichier(InputStream inp);
} |
Partager