Return-Path: Delivered-To: apmail-jakarta-poi-dev-archive@www.apache.org Received: (qmail 95371 invoked from network); 20 Oct 2003 22:02:38 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 20 Oct 2003 22:02:38 -0000 Received: (qmail 26580 invoked by uid 500); 20 Oct 2003 22:02:24 -0000 Delivered-To: apmail-jakarta-poi-dev-archive@jakarta.apache.org Received: (qmail 26568 invoked by uid 500); 20 Oct 2003 22:02:24 -0000 Mailing-List: contact poi-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "POI Developers List" Reply-To: "POI Developers List" Delivered-To: mailing list poi-dev@jakarta.apache.org Received: (qmail 26553 invoked from network); 20 Oct 2003 22:02:23 -0000 Received: from unknown (HELO exchange.sun.com) (192.18.33.10) by daedalus.apache.org with SMTP; 20 Oct 2003 22:02:23 -0000 Received: (qmail 16142 invoked by uid 50); 20 Oct 2003 22:05:35 -0000 Date: 20 Oct 2003 22:05:35 -0000 Message-ID: <20031020220535.16141.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: poi-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 23958] New: - Cannot get a the template feature to work when writing to an excel file. X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23958 Cannot get a the template feature to work when writing to an excel file. Summary: Cannot get a the template feature to work when writing to an excel file. Product: POI Version: 2.0-pre3 Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Major Priority: Other Component: POI Overall AssignedTo: poi-dev@jakarta.apache.org ReportedBy: mjmoore@strong.com I am trying to create a footer with formulas to set the printable area and footer text when printing the an excel report. When I implemented using a template to satisfy this requirement, the excel sheet started being created as blank. There is data being put into the object, but when I got to write that data to the excel sheet, it comes out as blank. Here is some sample code. Please let me know if I am doing something wrong here. public void generate(LevelOfProcessing aLevel, String excelFileTemplate, String excelFileName) throws ReportGenerationException { //clear out instance variables so this method //can be called multiple times for the same payroll file initialize(); this.level = aLevel; //this.excelFileTemplate = excelFileTemplate; createSpreadsheet(); createHeader(); writeExcelFile(excelFileName); } private void createSpreadsheet() { if (this.excelFileTemplate != null) { if (logging.isInfoEnabled()) { logging.info("Reading from excel template file " + this.excelFileTemplate); } try { InputStream templateStream = ClasspathResourceLocator.getResourceStream(this.excelFileTemplate); this.workbook = new ExcelWorkbook(templateStream); this.workbook = new ExcelWorkbook(); this.sheet = this.workbook.getSheet(REPORT_NAME); templateStream.close(); } catch (FileNotFoundException fnfe) { if (logging.isDebugEnabled()) { logging.debug("Unable to read from file " + this.excelFileTemplate + ". Creating a new workbook."); } this.workbook = new ExcelWorkbook(); this.sheet = this.workbook.createSheet(REPORT_NAME); } catch (IOException ioe) { if (logging.isDebugEnabled()) { logging.debug("Unable to read from file " + this.excelFileTemplate + ". Creating a new workbook."); } this.workbook = new ExcelWorkbook(); this.sheet = this.workbook.createSheet(REPORT_NAME); } catch (ResourceNotFoundException rnfe) { if (logging.isDebugEnabled()) { logging.debug("Unable to find file " + this.excelFileTemplate + ". Creating a new workbook."); } this.workbook = new ExcelWorkbook(); this.sheet = this.workbook.createSheet(REPORT_NAME); } } else { if (logging.isInfoEnabled()) { logging.info("Excel template file not specified. Creating a new workbook."); } this.workbook = new ExcelWorkbook(); this.sheet = this.workbook.createSheet(REPORT_NAME); } this.sheet.setColumnWidth((short) 0, (short) (15 * 256)); this.sheet.setColumnWidth((short) 1, (short) (12 * 256)); this.sheet.setColumnWidth((short) 2, (short) (10 * 256)); this.sheet.setColumnWidth((short) 3, (short) (50 * 256)); this.sheet.setColumnWidth((short) 4, (short) (13 * 256)); this.sheet.setColumnWidth((short) 5, (short) (35 * 256)); this.sheet.setColumnWidth((short) 6, (short) (35 * 256)); this.sheet.setFitToPage(true); } private void createHeader() { row = this.sheet.createRow(HEADER_ROW); ExcelCell cell = row.getOrCreateCell(HEADER_COLUMN); cell.setCellTypeString(); cell.setCellValue(STRONG); cell.setCellStyle(getTitleStyle()); row = this.sheet.createRow((short) (HEADER_ROW + 1)); cell = row.getOrCreateCell(HEADER_COLUMN); cell.setCellTypeString(); cell.setCellValue(REPORT_NAME); cell.setCellStyle(getTitleStyle()); } private void writeExcelFile(String excelFileName) throws ReportGenerationException { Long payrollKey = payrollData.getPayrollFile().getId().getLongValue ("payroll_file_key"); Long levelKey = this.level.getId().getLongValue("level_key"); try { if (logging.isInfoEnabled()) { logging.info("Writing edit report for payroll file key " + payrollKey.toString() + " and level key " + levelKey.toString() + " to file " + excelFileName); } FileOutputStream out = new FileOutputStream(excelFileName); this.workbook.write(out); out.close(); } catch (FileNotFoundException fnfe) { if (logging.isDebugEnabled()) { logging.debug("Unable to write to file " + excelFileName + " for payroll file key " + payrollKey.toString() + " and level key " + levelKey.toString(), fnfe); } throw new ReportGenerationException(fnfe, "Unable to write edit report to " + excelFileName); } catch (IOException ioe) { if (logging.isDebugEnabled()) { logging.debug("Unable to write to file " + excelFileName + " for payroll file key " + payrollKey.toString() + " and level key " + levelKey.toString(), ioe); } throw new ReportGenerationException(ioe, "Unable to write edit report to " + excelFileName); } } --------------------------------------------------------------------- To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: poi-dev-help@jakarta.apache.org