Package org.apache.poi.hssf.usermodel

Examples of org.apache.poi.hssf.usermodel.HSSFSheet.shiftRows()


      HSSFSheet s    = b.createSheet();
      HSSFRow row = s.createRow(4);
      row.createCell((short)0).setCellValue("test");
      s.setRowBreak(4);
     
      s.shiftRows(4, 4, 2);
      assertTrue("Row number 6 should have a pagebreak", s.isRowBroken(6));
     
    }
}
View Full Code Here


        HSSFWorkbook wb = new HSSFWorkbook( fin );
        fin.close();
        HSSFSheet s = wb.getSheetAt( 0 );

        // Shift the second row down 1 and write to temp file
        s.shiftRows( 1, 1, 1 );
        File tempFile = TempFile.createTempFile( "shift", "test.xls" );
        FileOutputStream fout = new FileOutputStream( tempFile );
        wb.write( fout );
        fout.close();
View Full Code Here

        assertEquals( s.getRow( 3 ).getPhysicalNumberOfCells(), 4 );
        assertEquals( s.getRow( 4 ).getPhysicalNumberOfCells(), 5 );

        // Shift rows 1-3 down 3 in the current one.  This tests when
        // 1 row is blank.  Write to a another temp file
        s.shiftRows( 0, 2, 3 );
        tempFile = TempFile.createTempFile( "shift", "test.xls" );
        fout = new FileOutputStream( tempFile );
        wb.write( fout );
        fout.close();
View Full Code Here

        wb = new HSSFWorkbook( fin );
        fin.close();
        s = wb.getSheetAt( 0 );

        // Shift rows 3 and 4 up and write to temp file
        s.shiftRows( 2, 3, -2 );
        tempFile = TempFile.createTempFile( "shift", "test.xls" );
        fout = new FileOutputStream( tempFile );
        wb.write( fout );
        fout.close();
View Full Code Here

    public void testShiftRow(){
     HSSFWorkbook b = new HSSFWorkbook();
     HSSFSheet s    = b.createSheet();
     s.createRow(0).createCell((short)0).setCellValue("TEST1");
     s.createRow(3).createCell((short)0).setCellValue("TEST2");
     s.shiftRows(0,4,1);
    }

    /**
     * Tests when shifting the first row.
     *
 
View Full Code Here

    public void testShiftRow0(){
     HSSFWorkbook b = new HSSFWorkbook();
     HSSFSheet s    = b.createSheet();
     s.createRow(0).createCell((short)0).setCellValue("TEST1");
     s.createRow(3).createCell((short)0).setCellValue("TEST2");
     s.shiftRows(0,4,1);
    }
   
    /**
     * When shifting rows, the page breaks should go with it
     *
 
View Full Code Here

      HSSFSheet s    = b.createSheet();
      HSSFRow row = s.createRow(4);
      row.createCell((short)0).setCellValue("test");
      s.setRowBreak(4);
     
      s.shiftRows(4, 4, 2);
      assertTrue("Row number 6 should have a pagebreak", s.isRowBroken(6));
     
    }

View Full Code Here

        assertEquals(comment3,"comment top row3 (index2)\n");
        String comment4 = sheet.getCellComment(3,0).getString().getString();
        assertEquals(comment4,"comment top row4 (index3)\n");

        // Shifting all but first line down to test comments shifting
        sheet.shiftRows(1, sheet.getLastRowNum(), 1, true, true);
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        wb.write(outputStream);

        // Test that comments were shifted as expected
        assertEquals(4, sheet.getLastRowNum());
View Full Code Here

        assertEquals("cell B3 (ref)", sheet.getRow(2).getCell((short)3).getRichStringCellValue().toString());
        assertEquals("CONCATENATE(B3,\" (ref)\")", sheet.getRow(2).getCell((short)3).getCellFormula());
        assertEquals("cell B2 (ref)", sheet.getRow(6).getCell((short)1).getRichStringCellValue().toString());
        assertEquals("CONCATENATE(B2,\" (ref)\")", sheet.getRow(6).getCell((short)1).getCellFormula());
       
        sheet.shiftRows(1, 1, 10);
       
        // Row 1 => Row 11
        // So strings on row 11 unchanged, but reference in formula is
        assertEquals("cell B1 (ref)", sheet.getRow(0).getCell((short)3).getRichStringCellValue().toString());
        assertEquals("CONCATENATE(B1,\" (ref)\")", sheet.getRow(0).getCell((short)3).getCellFormula());
View Full Code Here

        HSSFWorkbook wb = new HSSFWorkbook( fin );
        fin.close();
        HSSFSheet s = wb.getSheetAt( 0 );

        // Shift the second row down 1 and write to temp file
        s.shiftRows( 1, 1, 1 );
        File tempFile = File.createTempFile( "shift", "test.xls" );
        FileOutputStream fout = new FileOutputStream( tempFile );
        wb.write( fout );
        fout.close();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.