Package org.apache.poi.ss.util

Examples of org.apache.poi.ss.util.Region


    row = sheet.createRow(1);
    cell = row.createCell((short)1);
    cell.setCellValue(new HSSFRichTextString("second row, second cell"));

    Region region = new Region(1, (short)0, 1, (short)1);
    sheet.addMergedRegion(region);

    sheet.shiftRows(1, 1, 1);

    region = sheet.getMergedRegionAt(0);
    assertEquals("Merged region not moved over to row 2", 2, region.getRowFrom());
  }
View Full Code Here


    sheet.autoSizeColumn((short)0);
    assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth((short)0) >= minWithRow1And2);
    assertTrue("Column autosized with only one row: wrong width", sheet.getColumnWidth((short)0) <= maxWithRow1And2);

    //create a region over the 2nd row and auto size the first column
    sheet.addMergedRegion(new Region(1,(short)0,1,(short)1));
    sheet.autoSizeColumn((short)0);
    HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb);

    // check that the autoSized column width has ignored the 2nd row
    // because it is included in a merged region (Excel like behavior)
View Full Code Here

 
  public void testCloneSheetBasic(){
    try{
      HSSFWorkbook b = new HSSFWorkbook();
      HSSFSheet s = b.createSheet("Test");
      s.addMergedRegion(new Region((short)0,(short)0,(short)1,(short)1));
      HSSFSheet clonedSheet = b.cloneSheet(0);
     
      assertEquals("One merged area", 1, clonedSheet.getNumMergedRegions());

    }
View Full Code Here

  private void createDVTypeRowHSSFWorkbook wb, int sheetNo , HSSFCellStyle cellStyle, String strTypeDescription)
  {
    HSSFSheet sheet = wb.getSheetAt(sheetNo);
    HSSFRow row = sheet.createRow(sheet.getPhysicalNumberOfRows());
    row = sheet.createRow(sheet.getPhysicalNumberOfRows());
    sheet.addMergedRegion(new Region((short)(sheet.getPhysicalNumberOfRows()-1),(short)0,(short)(sheet.getPhysicalNumberOfRows()-1),(short)5));
    HSSFCell cell = row.createCell((short)0);
    cell.setCellValue(strTypeDescription);
    cell.setCellStyle(cellStyle);
    row = sheet.createRow(sheet.getPhysicalNumberOfRows());
  }
View Full Code Here

  private void createDVDeescriptionRowHSSFWorkbook wb, int sheetNo , HSSFCellStyle cellStyle, String strTypeDescription )
  {
    HSSFSheet sheet = wb.getSheetAt(sheetNo);
    HSSFRow row = sheet.getRow(sheet.getPhysicalNumberOfRows()-1);
    sheet.addMergedRegion(new Region((short)(sheet.getPhysicalNumberOfRows()-1),(short)0,(short)(sheet.getPhysicalNumberOfRows()-1),(short)5));
    HSSFCell cell = row.createCell((short)0);
    cell.setCellValue(strTypeDescription);
    cell.setCellStyle(cellStyle);
    row = sheet.createRow(sheet.getPhysicalNumberOfRows());
  }
View Full Code Here

    public void test22720() {
       HSSFWorkbook workBook = new HSSFWorkbook();
       workBook.createSheet("TEST");
       HSSFSheet template = workBook.getSheetAt(0);

       template.addMergedRegion(new Region(0, (short)0, 1, (short)2));
       template.addMergedRegion(new Region(1, (short)0, 2, (short)2));

       HSSFSheet clone = workBook.cloneSheet(0);
       int originalMerged = template.getNumMergedRegions();
       assertEquals("2 merged regions", 2, originalMerged);
View Full Code Here

    };

    short col = 1;
    Region [] regions =
    {
      new Region(0,col,65535,col)
    };

    sheetCF.addConditionalFormatting(regions, cfRules);
    sheetCF.addConditionalFormatting(regions, cfRules);

    // Verification
    assertEquals(2, sheetCF.getNumConditionalFormattings());
    sheetCF.removeConditionalFormatting(1);
    assertEquals(1, sheetCF.getNumConditionalFormattings());
    HSSFConditionalFormatting cf = sheetCF.getConditionalFormattingAt(0);
    assertNotNull(cf);

    regions = cf.getFormattingRegions();
    assertNotNull(regions);
    assertEquals(1, regions.length);
    Region r = regions[0];
    assertEquals(1, r.getColumnFrom());
    assertEquals(1, r.getColumnTo());
    assertEquals(0, r.getRowFrom());
    assertEquals(65535, r.getRowTo());

    assertEquals(2, cf.getNumberOfRules());

    rule1 = cf.getRule(0);
    assertEquals("7",rule1.getFormula1());
View Full Code Here


   
  private Region convertToRegion() {
   
    return new Region(_firstRow, (short)_firstColumn, _lastRow, (short)_lastColumn);
  }
View Full Code Here

            c = r.createCell(cellnum, HSSFCell.CELL_TYPE_BLANK);

            // c.setCellValue(0);
            c.setCellStyle(cs3);
        }
        s.addMergedRegion(new Region(( short ) 0, ( short ) 0, ( short ) 3,
                                     ( short ) 3));
        s.addMergedRegion(new Region(( short ) 100, ( short ) 100,
                                     ( short ) 110, ( short ) 110));

        // end draw thick black border
        // create a sheet, set its title then delete it
        s = wb.createSheet();
View Full Code Here

   
    protected CTSheet getSheet() {
        return this.sheet;
    }
    public int addMergedRegion(CellRangeAddress cra) {
      Region r = new Region(cra.getFirstRow(), (short)cra.getFirstColumn(),
          cra.getLastRow(), (short)cra.getLastColumn());
      return addMergedRegion(r);
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.ss.util.Region

Copyright © 2018 www.massapicom. 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.