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 53 54 55
|
public static Object getCellValue(HSSFSheet s, int rowNumber, int colNumber, Class classeSearch )
{
Row r=s.getRow(rowNumber);
Cell c= r.getCell(colNumber);
switch(classeSearch)
{
case Boolean.class:
return c.getBooleanCellValue();
case Date.class:
return c.getDateCellValue();
case Double.class:
return c.getNumericCellValue();
case String.class:
return getStringCellValue();
}
return null;
}
public static void main(String args[]) {
private Oject c1;
try{
InputStream i=new FileInputStream("b.xls");
POIFSFileSystem f=new POIFSFileSystem(i);
HSSFWorkbook w=new HSSFWorkbook(f);
HSSFSheet s= w. getSheetAt(0);
c1=add(getCellValue(s,1,2,String));
system.out.println("c1"+c1);
//
}catch(Exception e){ System.out.println("erreur1"+e.getMessage());}
}
} |
Partager