diff options
author | Glen Stampoultzis <glens@apache.org> | 2002-02-12 02:19:12 +0000 |
---|---|---|
committer | Glen Stampoultzis <glens@apache.org> | 2002-02-12 02:19:12 +0000 |
commit | 60cba30078201a67c2c69e6baaf93afcbe5fc9ee (patch) | |
tree | 67b17eecceac4ca500d2a2cbafd90d977338efd9 /src/testcases/org/apache/poi/hssf | |
parent | fc64c555f9291f1c5e7a6ad108d3fe78a86f6f46 (diff) | |
download | poi-60cba30078201a67c2c69e6baaf93afcbe5fc9ee.tar.gz poi-60cba30078201a67c2c69e6baaf93afcbe5fc9ee.zip |
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
Diffstat (limited to 'src/testcases/org/apache/poi/hssf')
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java | 26 |
1 files changed, 26 insertions, 0 deletions
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 @@ -136,6 +136,32 @@ public class TestCellStyle } /** + * 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 <P> * OBJECTIVE: Test that HSSF can create a simple spreadsheet with numeric and string values and styled with colors * and borders.<P> |