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
|
try
{
workbook = Workbook.getWorkbook(new File(fichier));//fichier source
String monfichier = "DéPAC"+compteur+".xls";
copy = Workbook.createWorkbook(new File(monfichier), workbook);//copie du fichier source
sheet2 = copy.getSheet(1);//on travail sur la feuile n°2
cell = sheet2.getWritableCell(1, 1);//numero de cellule (13,8) = (M,8)
if (cell.getType() == CellType.LABEL)//si le type de cellule est non-numérique (String)
{
String content = cell.getContents();
System.out.println("contenu actuel :"+ content);
Label lab = (Label) cell;
lab.setString("2,8");
}
else
{
if(cell.getType() == CellType.EMPTY)
{
//System.out.println("echec d'ecriture :"+cell.getType());
Label label = new Label(11, 9, "3,8");
sheet2.addCell(label);
}
else
{
if(cell.getType() == CellType.NUMBER)
{
cell.toString();
Label lab1 = (Label) cell;
lab1.setString("1,8");
}
else
System.out.println("echec d'ecriture :"+cell.getType());
}
copy.write();
copy.close();
} |
Partager