コード例 #1
0
 @Test
 public void testEmpty() {
   Sheet sheet = workbook.createSheet("test");
   Row row = sheet.createRow();
   assertEquals(0, row.getRowNo());
   writer.write(workbook, createFileOutputStream());
   Sheet result = readGeneratedFile().getSheet("test");
   assertNull(result.getValueAt(0, 0));
 }
コード例 #2
0
 @Test
 public void testString() {
   Sheet sheet = workbook.createSheet("test");
   Row row = sheet.createRow();
   row.getCellAt(0).setCellValue(new StringValue("haha"));
   writer.write(workbook, createFileOutputStream());
   Sheet result = readGeneratedFile().getSheet("test");
   assertEquals("haha", result.getValueAt(0, 0));
 }
コード例 #3
0
 @Test
 public void testNumeric() {
   Sheet sheet = workbook.createSheet("test");
   Row row = sheet.createRow();
   Double number = Double.valueOf(42);
   row.getCellAt(0).setCellValue(new NumericValue(number));
   writer.write(workbook, createFileOutputStream());
   Sheet result = readGeneratedFile().getSheet("test");
   assertEquals(number, result.getValueAt(0, 0));
 }
コード例 #4
0
 @Test
 public void testFormula() {
   Sheet sheet = workbook.createSheet("test");
   Row row = sheet.createRow();
   row.getCellAt(0).setCellValue(new NumericValue(1D));
   row.getCellAt(1).setCellValue(new NumericValue(2D));
   row.getCellAt(2).setCellValue(new FormulaValue("SUM(A1:B1)"));
   writer.write(workbook, createFileOutputStream());
   Sheet result = readGeneratedFile().getSheet("test");
   assertEquals("SUM(A1:B1)", result.getValueAt(0, 2));
 }
コード例 #5
0
 @Test
 public void testBoolean() {
   Sheet sheet = workbook.createSheet("test");
   Row row = sheet.createRow();
   row.getCellAt(0).setCellValue(new BooleanValue(true));
   row.getCellAt(1).setCellValue(new BooleanValue(false));
   writer.write(workbook, createFileOutputStream());
   Sheet result = readGeneratedFile().getSheet("test");
   assertEquals(Boolean.TRUE, result.getValueAt(0, 0));
   assertEquals(Boolean.FALSE, result.getValueAt(0, 1));
 }
コード例 #6
0
ファイル: PoiWorkbookWriter.java プロジェクト: gabe97330/jarb
 protected void createAndAddRow(Row row, HSSFSheet poiSheet, int rowNo) {
   HSSFRow poiRow = poiSheet.createRow(rowNo);
   for (int colNo = 0; colNo <= row.getLastCellNumber(); colNo++) {
     createAndAddCell(row.getCellAt(colNo), poiRow, colNo);
   }
 }