FileDocCategorySizeDatePackage
HSSFRegionUtil.javaAPI DocApache Poi 3.0.19355Mon Jan 01 12:39:34 GMT 2007org.apache.poi.hssf.usermodel.contrib

HSSFRegionUtil

public class HSSFRegionUtil extends Object
Various utility functions that make working with a region of cells easier.
author
Eric Pugh epugh@upstate.com
since
July 29, 2002

Fields Summary
Constructors Summary
private HSSFRegionUtil()
Constructor for the HSSFRegionUtil object

 
Methods Summary
public static voidsetBorderBottom(short border, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the borderBottom attribute of the HSSFRegionUtil object

param
border The new border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed

    int colStart = region.getColumnFrom();
    int colEnd = region.getColumnTo();
    int rowIndex = region.getRowTo();
    HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
    for ( int i = colStart; i <= colEnd; i++ ) {

      HSSFCell cell = HSSFCellUtil.getCell( row, i );
      HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderBottom", new Short( border ) );
    }
  
public static voidsetBorderLeft(short border, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the left border for a region of cells by manipulating the cell style of the indidual cells on the left

param
border The new border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed

    int rowStart = region.getRowFrom();
    int rowEnd = region.getRowTo();
    int column = region.getColumnFrom();

    for ( int i = rowStart; i <= rowEnd; i++ ) {
      HSSFRow row = HSSFCellUtil.getRow( i, sheet );
      HSSFCell cell = HSSFCellUtil.getCell( row, column );
      HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderLeft", new Short( border ) );
    }
  
public static voidsetBorderRight(short border, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the borderRight attribute of the HSSFRegionUtil object

param
border The new border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed

    int rowStart = region.getRowFrom();
    int rowEnd = region.getRowTo();
    int column = region.getColumnTo();

    for ( int i = rowStart; i <= rowEnd; i++ ) {
      HSSFRow row = HSSFCellUtil.getRow( i, sheet );
      HSSFCell cell = HSSFCellUtil.getCell( row, column );

      HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderRight", new Short( border ) );
    }
  
public static voidsetBorderTop(short border, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the borderBottom attribute of the HSSFRegionUtil object

param
border The new border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed

    int colStart = region.getColumnFrom();
    int colEnd = region.getColumnTo();
    int rowIndex = region.getRowFrom();
    HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
    for ( int i = colStart; i <= colEnd; i++ ) {

      HSSFCell cell = HSSFCellUtil.getCell( row, i );
      HSSFCellUtil.setCellStyleProperty( cell, workbook, "borderTop", new Short( border ) );
    }
  
public static voidsetBottomBorderColor(short color, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the bottomBorderColor attribute of the HSSFRegionUtil object

param
color The color of the border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed properly.

    int colStart = region.getColumnFrom();
    int colEnd = region.getColumnTo();
    int rowIndex = region.getRowTo();
    HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
    for ( int i = colStart; i <= colEnd; i++ ) {
      HSSFCell cell = HSSFCellUtil.getCell( row, i );
      HSSFCellUtil.setCellStyleProperty( cell, workbook, "bottomBorderColor", new Short( color ) );
    }
  
public static voidsetLeftBorderColor(short color, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the leftBorderColor attribute of the HSSFRegionUtil object

param
color The color of the border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed properly.

    int rowStart = region.getRowFrom();
    int rowEnd = region.getRowTo();
    int column = region.getColumnFrom();

    for ( int i = rowStart; i <= rowEnd; i++ ) {
      HSSFRow row = HSSFCellUtil.getRow( i, sheet );
      HSSFCell cell = HSSFCellUtil.getCell( row, column );
      HSSFCellUtil.setCellStyleProperty( cell, workbook, "leftBorderColor", new Short( color ) );
    }
  
public static voidsetRightBorderColor(short color, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the rightBorderColor attribute of the HSSFRegionUtil object

param
color The color of the border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed properly.

    int rowStart = region.getRowFrom();
    int rowEnd = region.getRowTo();
    int column = region.getColumnTo();

    for ( int i = rowStart; i <= rowEnd; i++ ) {
      HSSFRow row = HSSFCellUtil.getRow( i, sheet );
      HSSFCell cell = HSSFCellUtil.getCell( row, column );
      HSSFCellUtil.setCellStyleProperty( cell, workbook, "rightBorderColor", new Short( color ) );
    }
  
public static voidsetTopBorderColor(short color, org.apache.poi.hssf.util.Region region, org.apache.poi.hssf.usermodel.HSSFSheet sheet, org.apache.poi.hssf.usermodel.HSSFWorkbook workbook)
Sets the topBorderColor attribute of the HSSFRegionUtil object

param
color The color of the border
param
region The region that should have the border
param
workbook The workbook that the region is on.
param
sheet The sheet that the region is on.
exception
NestableException Thrown if the CellStyle can't be changed properly.

    int colStart = region.getColumnFrom();
    int colEnd = region.getColumnTo();
    int rowIndex = region.getRowFrom();
    HSSFRow row = HSSFCellUtil.getRow( rowIndex, sheet );
    for ( int i = colStart; i <= colEnd; i++ ) {
      HSSFCell cell = HSSFCellUtil.getCell( row, i );
      HSSFCellUtil.setCellStyleProperty( cell, workbook, "topBorderColor", new Short( color ) );

    }