com.extentech.ExtenXLS
Class ColHandle

java.lang.Object
  extended by com.extentech.ExtenXLS.ColHandle

public class ColHandle
extends Object

The ColHandle provides access to an Worksheet Column and its Cells.
Use the ColHandle to work with individual Columns in an XLS file.
With a ColHandle you can:

get a handle to the Cells in a column
set the default formatting for a column

Note: for a discussion of Column widths see: http://support.microsoft.com/?kbid=214123

Since:
1.3
Version:
4.1
Author:
John McMahon -- Copyright ©2011Extentech Inc.
See Also:
WorkBookHandle, WorkSheetHandle, FormulaHandle

Field Summary
static int DEFAULT_COLWIDTH
           
 
Method Summary
 void autoFit()
          resizes this column to fit the width of all displayed, non-wrapped text.
 boolean containsMergeRange()
          determines if this Column passes through i.e.
 CellHandle[] getCells()
          returns the array of Cells in this Column
 int getColFirst()
          returns the first Column referenced by this column handle
NOTE: A Column handle may in some circumstances refer to a range of columns
 int getColLast()
          returns the last Column referenced by this column handle
NOTE: A Column handle may in some circumstances refer to a range of columns
 FormatHandle getFormatHandle()
          returns the FormatHandle (a Format Object describing visual properties) for this Column
NOTE: The Column format record describes the default formatting for each cell contained within the column
 int getFormatId()
          returns the format ID (the index to the format record) for this Column
The Column format is the default formatting for each cell contained within the column
 int getOutlineLevel()
          Returns the Outline level (depth) of this Column
 int getWidth()
          returns the width of this Column in internal units defined as follows:
default width of the columns in 1/256 of the width of the zero character, using default font.
static int getWidth(com.extentech.formats.XLS.Boundsheet sheet, int col)
          static utility method to return the Column width of an existing column in the units as follows:
default width of the columns in 1/256 of the width of the zero character, using default font.
 int getWidthInChars()
          returns the width of this Column in Characters or regular Excel units
NOTE: this value is a calculated value that should be close but still is an approximation of Excel units
 boolean isCollapsed()
          returns true if this Column is collapsed
 boolean isHidden()
          returns true if this Column is hidden
 void setCol(com.extentech.formats.XLS.Col c)
          sets this ColHandle source Column
 void setCollapsed(boolean b)
          sets whether to collapse this Column
 void setFormatId(int i)
          sets the format id (an index to a Format record) for this Column
This sets the default formatting for the Column such that any cell that does not specifically set it's own formatting will display this Column formatting
 void setHidden(boolean b)
          sets whether to hide or show this Column
 void setOutlineLevel(int x)
          Set the Outline level (depth) of this Column
 void setWidth(int newWidth)
          sets the width of this Column in internal units, described as follows:
default width of the columns in 1/256 of the width of the zero character, using default font.
 void setWidthInChars(int newWidth)
          sets the width of this Column in Characters or Excel units.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COLWIDTH

public static final int DEFAULT_COLWIDTH
See Also:
Constant Field Values
Method Detail

autoFit

public void autoFit()
resizes this column to fit the width of all displayed, non-wrapped text.
NOTE: as the Excel autofit implementation is undocumented, this is an approximation


setCol

public void setCol(com.extentech.formats.XLS.Col c)
sets this ColHandle source Column

Parameters:
col - c - source Column object

setWidthInChars

public void setWidthInChars(int newWidth)
sets the width of this Column in Characters or Excel units.
The default Excel column width is set to 8.43 Characters, based on the default font and font size,
NOTE: The last Cell in the column having its width set will be the resulting width of the column

Parameters:
int - i - desired Column width in Characters (Excel units)

setWidth

public void setWidth(int newWidth)
sets the width of this Column in internal units, described as follows:
default width of the columns in 1/256 of the width of the zero character, using default font.
The Default Excel Column, whose width in Characters or Excel Units, is 8.43, has a width in these units of 2300.

NOTE: The last Cell in the column having its width set will be the resulting width of the column

Parameters:
int - i - desired Column width in internal units

getWidth

public int getWidth()
returns the width of this Column in internal units defined as follows:
default width of the columns in 1/256 of the width of the zero character, using default font.
The Default Excel Column, whose width in Excel Units or Characters is 8.43, has a width in these units of 2300.

Returns:
int Column width in internal units

getWidthInChars

public int getWidthInChars()
returns the width of this Column in Characters or regular Excel units
NOTE: this value is a calculated value that should be close but still is an approximation of Excel units

Returns:
int Column width in Excel units

getWidth

public static int getWidth(com.extentech.formats.XLS.Boundsheet sheet,
                           int col)
static utility method to return the Column width of an existing column in the units as follows:
default width of the columns in 1/256 of the width of the zero character, using default font.
The Default Excel Column, whose width in Characters or Excel Units is 8.43, has a width in these units of 2300.

Parameters:
Boundsheet - sheet - source Worksheet
int - col - 0-based Column number
Returns:
int - Column width in internal units

setFormatId

public void setFormatId(int i)
sets the format id (an index to a Format record) for this Column
This sets the default formatting for the Column such that any cell that does not specifically set it's own formatting will display this Column formatting

Parameters:
int - i - ID representing the Format to set this Column
See Also:
FormatHandle

getFormatId

public int getFormatId()
returns the format ID (the index to the format record) for this Column
The Column format is the default formatting for each cell contained within the column

Returns:
int formatId - the index of the format record for this Column
See Also:
FormatHandle

getFormatHandle

public FormatHandle getFormatHandle()
returns the FormatHandle (a Format Object describing visual properties) for this Column
NOTE: The Column format record describes the default formatting for each cell contained within the column

Returns:
FormatHandle - a Format object to apply to this Col

getColFirst

public int getColFirst()
returns the first Column referenced by this column handle
NOTE: A Column handle may in some circumstances refer to a range of columns

Returns:
int first column number referenced by this Column handle

getColLast

public int getColLast()
returns the last Column referenced by this column handle
NOTE: A Column handle may in some circumstances refer to a range of columns

Returns:
int last column number referenced by this Column handle

getCells

public CellHandle[] getCells()
returns the array of Cells in this Column

Returns:
CellHandle array

containsMergeRange

public boolean containsMergeRange()
determines if this Column passes through i.e. contains a horizontal merge range

Returns:
true if this Column is part of any merge (horizontally merged cells)

setCollapsed

public void setCollapsed(boolean b)
sets whether to collapse this Column

Parameters:
boolean - b - true to collapse this Column

setHidden

public void setHidden(boolean b)
sets whether to hide or show this Column

Parameters:
boolean - b - true to hide this Column, false to show

setOutlineLevel

public void setOutlineLevel(int x)
Set the Outline level (depth) of this Column

Parameters:
int - x - outline level

getOutlineLevel

public int getOutlineLevel()
Returns the Outline level (depth) of this Column

Returns:
int outline level

isCollapsed

public boolean isCollapsed()
returns true if this Column is collapsed

Returns:
true if ths Column is collapsed, false otherwise

isHidden

public boolean isHidden()
returns true if this Column is hidden

Returns:
true if this Column is hidden, false if not


Copyright © 2011 Extentech Inc. All Rights Reserved.