Added (test first) test case for if formulas

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352833 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-09-02 16:13:48 +00:00
parent e9c40534df
commit 72965e9a0d
2 changed files with 33 additions and 0 deletions

View File

@ -858,6 +858,39 @@ extends TestCase {
}
public void testIfFormulas()
throws java.io.IOException
{
String readFilename = System.getProperty("HSSF.testdata.path");
File file = File.createTempFile("testIfFormula",".xls");
FileOutputStream out = new FileOutputStream(file);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet("Sheet1");
HSSFRow r = null;
HSSFCell c = null;
r = s.createRow((short)0);
c=r.createCell((short)1); c.setCellValue(1);
c=r.createCell((short)2); c.setCellValue(2);
c=r.createCell((short)3); c.setCellFormula("MAX(A1:B1)");
c=r.createCell((short)4); c.setCellFormula("IF(A1=D1,\"A1\",\"B1\")");
wb.write(out);
out.close();
assertTrue("file exists",file.exists());
FileInputStream in = new FileInputStream(readFilename+File.separator+"IfFormulaTest.xls");
wb = new HSSFWorkbook(in);
s = wb.getSheetAt(0);
r = s.getRow(3);
c = r.getCell((short)0);
assertTrue("expected: IF(A3=A1,\"A1\",\"B1\") got "+c.getCellFormula(), ("IF(A3=A1,\"A1\",\"B1\")").equals(c.getCellFormula()));
//c = r.getCell((short)1);
//assertTrue("expected: A!A1+A!B1 got: "+c.getCellFormula(), ("A!A1+A!B1").equals(c.getCellFormula()));
in.close();
}
public static void main(String [] args) {
System.out
.println("Testing org.apache.poi.hssf.usermodel.TestFormulas");