Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1146 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  [JXL] Conservation des propriétés

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[JXL] Conservation des propriétés

n°2023451
TomZ
Posté le 17-09-2010 à 09:29:32  profilanswer
 

Bonjour à tous  :hello: ,
 
Petit souci avec la librairies JXL (dernière en date). Je veux écrire un fichier Excel à partir d'un template. Pas de problème ça marche bien sauf que le fichier possède des propriétés spécifiques (revision number et identification number).  
 
http://img97.imageshack.us/img97/8199/prtscrcapturev.png
 
Ces propriétés ne sont pas recopiées avec JXL. La méthode createWorkbook va totalement squizzer les propriétés.
 
Ci-dessous le code :
 

Code :
  1. /**
  2.      * Generate the Excel file linked to the form
  3.      * @param _Bean : the Bean
  4.      * @throws IOException : catched in the caller method
  5.      * @throws BiffException : catched in the caller method
  6.      * @throws WriteException : catched in the caller method
  7.      */
  8.     private void generateExcel(EarlyInvoicingBean _Bean) throws BiffException, IOException, WriteException{
  9.        
  10.         if (LOG.isInfo()){
  11.             LOG.info("[" + KEY_WORD_LOG + "] - generateExcel - Begin" );
  12.         }
  13.        
  14.         File vExcelTemplate = new File(excelTemplate);
  15.         String vExcelGeneratedName = EarlyInvoicingSvc.generateRandomID() + ".xls";
  16.         File vExcelGenerated = new File(excelGenerated + vExcelGeneratedName);
  17.        
  18.         WorkbookSettings vWorkBookSettings = new WorkbookSettings();
  19.         vWorkBookSettings.setEncoding( "ISO-8859-1" );
  20.        
  21.         //Open the current template
  22.         Workbook vWorkbook = Workbook.getWorkbook(vExcelTemplate, vWorkBookSettings);
  23.         //Copy it to work on this template  
  24.         WritableWorkbook vCopy = Workbook.createWorkbook(vExcelGenerated, vWorkbook);
  25.         //Select the sheet to fill
  26.         WritableSheet vSheetToWrite = vCopy.getSheet(0);
  27.         //Retrieve the cell to write
  28.         WritableCell vRequester = vSheetToWrite.getWritableCell(1, 9);
  29.         WritableCell vRequesterMail = vSheetToWrite.getWritableCell(1, 25);
  30.         WritableCell vSAPNbr = vSheetToWrite.getWritableCell(4, 11);
  31.         WritableCell vRequestDate = vSheetToWrite.getWritableCell(4, 21);
  32.         WritableCell vCustomerMail = vSheetToWrite.getWritableCell(1, 23);
  33.         if (vRequester.getType() == CellType.LABEL)
  34.         {
  35.             Label vValue = (Label) vRequester;
  36.             vValue.setString(_Bean.getRequesterForename() + " " + _Bean.getRequesterName());
  37.         }
  38.         if (vRequesterMail.getType() == CellType.LABEL)
  39.         {
  40.             Label vValue = (Label) vRequesterMail;
  41.             vValue.setString(_Bean.getRequesterMail());
  42.         }
  43.         if (vSAPNbr.getType() == CellType.LABEL)
  44.         {
  45.             Label vValue = (Label) vSAPNbr;
  46.             vValue.setString(_Bean.getSAPNbr());
  47.         }
  48.         if (vRequestDate.getType() == CellType.LABEL)
  49.         {
  50.             Label vValue = (Label) vRequestDate;
  51.             vValue.setString(_Bean.getInvoiceAskedDateString());
  52.         }
  53.         if (vCustomerMail.getType() == CellType.LABEL)
  54.         {
  55.             Label vValue = (Label) vCustomerMail;
  56.             vValue.setString(_Bean.getCustomerMail());
  57.         }
  58.         //All cells modified/added. Now write out the workbook
  59.         vCopy.write();
  60.         vCopy.close();
  61.        
  62.        
  63.         if (LOG.isInfo()){
  64.             LOG.info("[" + KEY_WORD_LOG + "] - generateExcel - End" );
  65.         }
  66.        
  67.         _Bean.setExcelFileName(vExcelGeneratedName);
  68.     }


 
Avez-vous une solution pour ce problème ?
 
Merci d'avance.


Message édité par TomZ le 17-09-2010 à 09:37:26
mood
Publicité
Posté le 17-09-2010 à 09:29:32  profilanswer
 

n°2023799
TomZ
Posté le 20-09-2010 à 10:47:08  profilanswer
 

Bonjour à tous,
 
Je suis passé à POI d'Apache pour régler mon problème. De toute façon, JXL ne gère pas le format XLSX des nouvelles versions d'office.  
 
J'ai donc une solution de contournement.


Message édité par TomZ le 20-09-2010 à 10:58:33

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  [JXL] Conservation des propriétés

 

Sujets relatifs
Extraction des métadonnées encoder en rdf avec javaSvn import puis checkout et conservation des droits
JXL: definir plusieurs borderconservation de droits avec cwrsync
conservation de données formulaires en cas de retour[XSL] Conservation d'éléments après transformation
Conservation du profil entre 2 sitesListe déroulante avec onchange et conservation des données précédentes
[php] redirection avec conservation de $_POST[ JEXCEL/JXL] Récupération d'un lien hypertexte dans un cellule
Plus de sujets relatifs à : [JXL] Conservation des propriétés


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR