From 60cba30078201a67c2c69e6baaf93afcbe5fc9ee Mon Sep 17 00:00:00 2001 From: Glen Stampoultzis Date: Tue, 12 Feb 2002 02:19:12 +0000 Subject: Added methods for date reading and writing on HSSFCell. git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352092 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/usermodel/TestCellStyle.java | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/testcases/org/apache/poi') diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java index 20d06b071f..49f49c6e5d 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java @@ -135,6 +135,32 @@ public class TestCellStyle // assert((s.getLastRowNum() == 99)); } + /** + * Tests that is creating a file with a date works correctly. + */ + public void testDataStyle() + throws Exception + { + File file = File.createTempFile("testWriteSheetStyleDate", + ".xls"); + FileOutputStream out = new FileOutputStream(file); + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet s = wb.createSheet(); + HSSFCellStyle cs = wb.createCellStyle(); + HSSFRow row = s.createRow((short)0); + HSSFCell cell = row.createCell((short)1); + cs.setDataFormat(HSSFDataFormat.getFormat("m/d/yy")); + cell.setCellStyle(cs); + cell.setCellValue(new Date()); + wb.write(out); + out.close(); + + assertEquals("FILE LENGTH ", 5632, file.length()); + assertEquals("LAST ROW ", 0, s.getLastRowNum()); + assertEquals("FIRST ROW ", 0, s.getFirstRowNum()); + + } + /** * TEST NAME: Test Write Sheet Style

* OBJECTIVE: Test that HSSF can create a simple spreadsheet with numeric and string values and styled with colors -- cgit v1.2.3