Bonjour à tous ,
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).
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 :
- /**
- * Generate the Excel file linked to the form
- * @param _Bean : the Bean
- * @throws IOException : catched in the caller method
- * @throws BiffException : catched in the caller method
- * @throws WriteException : catched in the caller method
- */
- private void generateExcel(EarlyInvoicingBean _Bean) throws BiffException, IOException, WriteException{
-
- if (LOG.isInfo()){
- LOG.info("[" + KEY_WORD_LOG + "] - generateExcel - Begin" );
- }
-
- File vExcelTemplate = new File(excelTemplate);
- String vExcelGeneratedName = EarlyInvoicingSvc.generateRandomID() + ".xls";
- File vExcelGenerated = new File(excelGenerated + vExcelGeneratedName);
-
- WorkbookSettings vWorkBookSettings = new WorkbookSettings();
- vWorkBookSettings.setEncoding( "ISO-8859-1" );
-
- //Open the current template
- Workbook vWorkbook = Workbook.getWorkbook(vExcelTemplate, vWorkBookSettings);
- //Copy it to work on this template
- WritableWorkbook vCopy = Workbook.createWorkbook(vExcelGenerated, vWorkbook);
- //Select the sheet to fill
- WritableSheet vSheetToWrite = vCopy.getSheet(0);
- //Retrieve the cell to write
- WritableCell vRequester = vSheetToWrite.getWritableCell(1, 9);
- WritableCell vRequesterMail = vSheetToWrite.getWritableCell(1, 25);
- WritableCell vSAPNbr = vSheetToWrite.getWritableCell(4, 11);
- WritableCell vRequestDate = vSheetToWrite.getWritableCell(4, 21);
- WritableCell vCustomerMail = vSheetToWrite.getWritableCell(1, 23);
- if (vRequester.getType() == CellType.LABEL)
- {
- Label vValue = (Label) vRequester;
- vValue.setString(_Bean.getRequesterForename() + " " + _Bean.getRequesterName());
- }
- if (vRequesterMail.getType() == CellType.LABEL)
- {
- Label vValue = (Label) vRequesterMail;
- vValue.setString(_Bean.getRequesterMail());
- }
- if (vSAPNbr.getType() == CellType.LABEL)
- {
- Label vValue = (Label) vSAPNbr;
- vValue.setString(_Bean.getSAPNbr());
- }
- if (vRequestDate.getType() == CellType.LABEL)
- {
- Label vValue = (Label) vRequestDate;
- vValue.setString(_Bean.getInvoiceAskedDateString());
- }
- if (vCustomerMail.getType() == CellType.LABEL)
- {
- Label vValue = (Label) vCustomerMail;
- vValue.setString(_Bean.getCustomerMail());
- }
- //All cells modified/added. Now write out the workbook
- vCopy.write();
- vCopy.close();
-
-
- if (LOG.isInfo()){
- LOG.info("[" + KEY_WORD_LOG + "] - generateExcel - End" );
- }
-
- _Bean.setExcelFileName(vExcelGeneratedName);
- }
|
Avez-vous une solution pour ce problème ?
Merci d'avance.
Message édité par TomZ le 17-09-2010 à 09:37:26