ASF Bugzilla – Attachment 13041 Details for
Bug 31661
HSSFCell.getCellFormula() fails with references to external workbooks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test case
TestGetFormulaExternal.java (text/plain), 2.59 KB, created by
Gerry Matte
on 2004-10-12 06:05:36 UTC
(
hide
)
Description:
Test case
Filename:
MIME Type:
Creator:
Gerry Matte
Created:
2004-10-12 06:05:36 UTC
Size:
2.59 KB
patch
obsolete
>import java.io.*; >import org.apache.poi.poifs.filesystem.POIFSFileSystem; >import org.apache.poi.hssf.usermodel.HSSFWorkbook; >import org.apache.poi.hssf.usermodel.HSSFSheet; >import org.apache.poi.hssf.usermodel.HSSFRow; >import org.apache.poi.hssf.usermodel.HSSFCell; > >/** > * <p>Description: This program reads an Excel 2003 spreadsheet that references > * another spreadsheet from cell K12 of sheet Account Number Master. > * This example illustrates an error in the Jakarta POI 2.5.1 package.</p> > * <p>The <code>HSSFCell.getCellFormula()</code> returns the name of this cell's > * sheet not the external workbook and sheet name of the referenced cell in the > * external workbook. No workaround is available.</p> > * In an Excel 2003 workbook <code>IT2005short.xls</code> at sheet > * <code>Account Number Master</code> at > * cell K12 is the formula <br> > * <code> > * =<b>+'C:\d\myPrograms\jbproject\POI1\[GM Budget.xls]8085.4450'</b>!$B$2 > * </code><br> > * but the formula returned by HSSFCell.getFormulaString() is <br> > * <code><b>+Account Number Master</b>!$B$2</code>. > * </p> > * <p>Note: The original bugzilla report # 31661 reported that a second error existed - > * HSSFRowget.PhysicalNumberOfCells() was reported to be one too small. > * Such is <b>not</b> the case as proven by this test program.</p> > * @author Gerry Matte {@link matteg@saanich.ca}<br>Municipality of Saanich {@link http://www.saanich.ca} > * @version 1.0 Oct 11, 2004 > */ >public class TestGetFormulaExternal { > public TestGetFormulaExternal() { > } > public static void main(String[] args) { > String input = "C:/d/myPrograms/jbproject/POI1/IT2005short.xls"; > System.out.println("Input: "+input); > FileInputStream fis = null; > POIFSFileSystem fs = null; > HSSFWorkbook wb = null; > try { > fis = new FileInputStream(input); > fs = new POIFSFileSystem(fis); > wb = new HSSFWorkbook(fs); > } > catch (FileNotFoundException nf) { > System.out.println(nf.getMessage()); > System.exit(1); > } > catch (IOException io) { > System.out.println(io.getMessage()); > System.exit(1); > }; > HSSFSheet sheet = wb.getSheetAt(0); > HSSFRow row = sheet.getRow(11); // Row 12 > System.out.println("row contains "+ > row.getPhysicalNumberOfCells()+ > " physical number of cells"); > HSSFCell cellK12 = row.getCell((short)10); // cell K12 > String cellK12Formula = cellK12.getCellFormula(); > System.out.println("CellK12 formula="+cellK12Formula); > try { > fis.close(); > } > catch (IOException io) { > System.out.println(io.getMessage()); > System.exit(1); > }; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 31661
:
13037
|
13038
|
13039
|
13040
| 13041