mirror of https://github.com/apache/poi.git
unit test for date formula
PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352898 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2fd37fea2c
commit
3f030802f1
|
@ -857,6 +857,43 @@ extends TestCase {
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testDateFormulas()
|
||||||
|
throws java.io.IOException
|
||||||
|
{
|
||||||
|
String readFilename = System.getProperty("HSSF.testdata.path");
|
||||||
|
|
||||||
|
File file = File.createTempFile("testDateFormula",".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)0 );
|
||||||
|
|
||||||
|
HSSFCellStyle cellStyle = wb.createCellStyle();
|
||||||
|
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
|
||||||
|
c.setCellValue(new Date());
|
||||||
|
c.setCellStyle(cellStyle);
|
||||||
|
|
||||||
|
// assertEquals("Checking hour = " + hour, date.getTime().getTime(),
|
||||||
|
// HSSFDateUtil.getJavaDate(excelDate).getTime());
|
||||||
|
|
||||||
|
for (int k=1; k < 100; k++) {
|
||||||
|
r=s.createRow((short)k);
|
||||||
|
c=r.createCell((short)0);
|
||||||
|
c.setCellFormula("A"+(k)+"+1");
|
||||||
|
c.setCellStyle(cellStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
wb.write(out);
|
||||||
|
out.close();
|
||||||
|
|
||||||
|
assertTrue("file exists",file.exists());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public void testIfFormulas()
|
public void testIfFormulas()
|
||||||
throws java.io.IOException
|
throws java.io.IOException
|
||||||
|
|
Loading…
Reference in New Issue