Modifié le contenu le contenu d'un fichier EXCEL en utilisant JEXCEL API

info20072008 Messages postés 12 Date d'inscription mercredi 12 mars 2008 Statut Membre Dernière intervention 1 mai 2009 - 26 janv. 2009 à 11:29
soufianetomase Messages postés 1 Date d'inscription samedi 25 mars 2006 Statut Membre Dernière intervention 3 avril 2009 - 3 avril 2009 à 10:49
bonjour,
j'utilise JEXCEL API  pour manipuler des fichier EXCEL
je recupère un fichier EXCEL que j'ai bien organisé et je veux le remplir pour cela : je le copie dans un autre pour pouvoir faire des modifications
comme suit
<hr />Workbook workbook = Workbook. getWorkbook (

new File(projectRealPath,
"bon/ready.xls"));

WritableWorkbook copy = Workbook.createWorkbook(

new File(
"ReadyDistribution.xls"), workbook);
//copie du fichier source WritableSheet sheet4 = copy.getSheet(4);

//on travail sur la feuile n°4
<hr />comment je puisse modifié le contenu d'une cellule de la feuille "sheet4"?
car quand j'ai fais ça :

<hr />WritableCell cell = sheet4.getWritableCell(i, j);

Label label =

new Label (i, j, qte); sheet4.addCell(label);

<hr />il m'insère la valeur voulu ma la cellule à perdu sa couleur elle est devenu blanche
moi je veux juste modifié le contenu
comment je puisse faire ça
merci de me répondre

2 réponses

upline Messages postés 1 Date d'inscription mercredi 18 février 2009 Statut Membre Dernière intervention 18 février 2009
18 févr. 2009 à 17:58
salam
0
soufianetomase Messages postés 1 Date d'inscription samedi 25 mars 2006 Statut Membre Dernière intervention 3 avril 2009
3 avril 2009 à 10:49
bonjour,
tiens un exemple de ce que tu veux :

import java.io.File;
import java.io.IOException;

import jxl.Cell;
import jxl.Workbook;
import jxl.read.biff.BiffException;
import jxl.write.Label;
import jxl.write.WritableCell;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

public class ExcelModifier {
    static WritableWorkbook copy;
    public static void main(String[] args) throws BiffException, IOException, RowsExceededException, WriteException {

        String filePath =System.getProperty("user.dir")+"\\target\\template.xls";
         Workbook workbook = Workbook.getWorkbook(new File(filePath));
                  copy = Workbook.createWorkbook(
                 new File(System.getProperty("user.dir")+"\\target\\monfichier.xls"), workbook);//copie du fichier source
                 WritableSheet DATA2 = copy.getSheet("DATA2");
                 WritableCell cell = DATA2.getWritableCell(0, 0);
                 System.err.println(cell.getContents());
                 Label label = new Label (1, 0, "motche",cell.getCellFormat());//(colonne,ligne)
                 DATA2.addCell(label);
                 copy.write();
                 copy.close();
                 workbook.close();
    }
   
 
}
0
Rejoignez-nous