Return-Path: Delivered-To: apmail-poi-dev-archive@www.apache.org Received: (qmail 46124 invoked from network); 22 May 2008 11:17:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 May 2008 11:17:27 -0000 Received: (qmail 98036 invoked by uid 500); 22 May 2008 11:17:28 -0000 Delivered-To: apmail-poi-dev-archive@poi.apache.org Received: (qmail 97962 invoked by uid 500); 22 May 2008 11:17:28 -0000 Mailing-List: contact dev-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Developers List" Delivered-To: mailing list dev@poi.apache.org Received: (qmail 97951 invoked by uid 99); 22 May 2008 11:17:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 May 2008 04:17:28 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 May 2008 11:16:42 +0000 Received: by brutus.apache.org (Postfix, from userid 33) id 88D40234C11B; Thu, 22 May 2008 04:17:03 -0700 (PDT) From: bugzilla@apache.org To: dev@poi.apache.org Subject: DO NOT REPLY [Bug 45060] New: Formula written incorrectly produces #VALUE error X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: newchanged X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: POI X-Bugzilla-Component: HSSF X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cpuidle@gmx.de X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dev@poi.apache.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 22 May 2008 04:17:03 -0700 (PDT) X-Virus-Checked: Checked by ClamAV on apache.org https://issues.apache.org/bugzilla/show_bug.cgi?id=45060 Summary: Formula written incorrectly produces #VALUE error Product: POI Version: 3.0-dev Platform: PC OS/Version: Windows XP Status: NEW Severity: normal Priority: P3 Component: HSSF AssignedTo: dev@poi.apache.org ReportedBy: cpuidle@gmx.de Blocks: 45041 This is a follow-on issue to bug 45041. The following example creates a sheet with two rows as input data for the final formula in row 3. The formula produces a #VALUE error in excel (tested on poi 3.1beta). Visually the formula in Excel appears ok. Just pressing "Enter" in the formula field again fixes the problem and field displays a value. It seems Excel is correcting the formula in the background- visually it does not change by this process. import java.io.*; import java.util.*; import org.apache.poi.hssf.usermodel.*; public class Test { static int row = 0; static HSSFSheet sheet; static HSSFCellStyle xlsDateStyle, xlsNumericStyle, xlsPercentStyle; /** * @param args * @throws Exception */ public static void main(String[] args) throws Exception { FileOutputStream out = new FileOutputStream("d:\\test.xls"); HSSFWorkbook wb = new HSSFWorkbook(); sheet = wb.createSheet("test"); // Excel-formatted date object xlsDateStyle = wb.createCellStyle(); xlsDateStyle.setDataFormat(wb.createDataFormat().getFormat("dd.mm.yyyy")); // Excel-formatted number xlsNumericStyle = wb.createCellStyle(); xlsNumericStyle.setDataFormat(wb.createDataFormat().getFormat("0.00")); // Excel-formatted percent object xlsPercentStyle = wb.createCellStyle(); xlsPercentStyle.setDataFormat(wb.createDataFormat().getFormat("0.00%")); addRow(new Date(0, 0, 1), 100.0); addRow(new Date(1, 0, 1), -110.0); HSSFRow r = sheet.createRow(row++); // create the IRR formula short col = 2; HSSFCell c = r.createCell(col++); c.setCellStyle(xlsPercentStyle); c.setCellType(HSSFCell.CELL_TYPE_FORMULA); c.setCellFormula("(1+IRR(SUMIF(A:A,ROW(INDIRECT(MIN(A:A)&\":\"&MAX(A:A))),B:B),0))^365-1"); wb.write(out); out.close(); } private static void addRow(Date date, double d) { HSSFRow r = sheet.createRow(row++); short col = 0; HSSFCell c = r.createCell(col++); c.setCellValue(date); c.setCellStyle(xlsDateStyle); c = r.createCell(col++); c.setCellValue(d); c.setCellStyle(xlsNumericStyle); } } -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org For additional commands, e-mail: dev-help@poi.apache.org