aspose.cells

Class Column

Represents a single column in a worksheet.

Example:

//Instantiating a Workbook object
//Instantiating a Workbook object
$workbook = new cells\Workbook();
//Obtaining the reference of the first worksheet
$worksheet = $workbook->getWorksheets()->get(0);
$style = $workbook->createStyle();
//Setting the background color to Blue
$style->setBackgroundColor(cells\Color::getBlue());

//Setting the foreground color to Red
$style->setForegroundColor(cells\Color::getRed());

//setting Background Pattern
$style->setPattern(cells\BackgroundType::DIAGONAL_STRIPE);

//New Style Flag
$styleFlag = new cells\StyleFlag();

//Set All Styles
$styleFlag->setAll(true);

//Get first Column
$column = $worksheet->getCells()->getColumns()->get(0);

//Apply Style to first Column
$column->applyStyle($style, $styleFlag);

Property Getters/Setters Summary
functiongetGroupLevel()
function
           Gets the group level of the column.
functionhasCustomStyle()
Indicates whether this column has custom style settings(different from the default one inherited from workbook).
functiongetIndex()
Gets the index of this column.
functionisCollapsed()
function
           whether the column is collapsed
functionisHidden()
function
setHidden(value)
           Indicates whether the column is hidden.
functiongetWidth()
function
setWidth(value)
           Gets and sets the column width in unit of characters.
 
Method Summary
functionapplyStyle(style, flag)
Applies formats for a whole column.
functiongetStyle()
Gets the style of this column.
functionsetStyle(style)
Sets the style of this column.
 

    • Property Getters/Setters Detail

      • getIndex : Number 

        function getIndex()
        
        Gets the index of this column.
      • getWidth/setWidth : Number 

        function getWidth() / function setWidth(value)
        
        Gets and sets the column width in unit of characters. For spreadsheet, column width is measured as the number of characters of the maximum digit width of the numbers 0~9 as rendered in the normal style's font.
      • getGroupLevel/setGroupLevel : byte 

        function getGroupLevel() / function setGroupLevel(value)
        
        Gets the group level of the column.
      • isHidden/setHidden : boolean 

        function isHidden() / function setHidden(value)
        
        Indicates whether the column is hidden.
      • hasCustomStyle : boolean 

        function hasCustomStyle()
        
        Indicates whether this column has custom style settings(different from the default one inherited from workbook).
      • isCollapsed/setCollapsed : boolean 

        function isCollapsed() / function setCollapsed(value)
        
        whether the column is collapsed
    • Method Detail

      • applyStyle

        function applyStyle(style, flag)
        Applies formats for a whole column.
        Parameters:
        style: Style - The style object which will be applied.
        flag: StyleFlag - Flags which indicates applied formatting properties.
      • getStyle

        function getStyle()
        Gets the style of this column. Modifying the returned style object directly takes no effect for this column or any cells in this column. You have to call applyStyle(com.aspose.cells.Style, com.aspose.cells.StyleFlag) or setStyle(com.aspose.cells.Style) method to apply the change to this column.
        Column's style is the style which will be inherited by cells in this column(those cells that have no custom style settings, such as existing cells that have not been set style explicitly, or those that have not been instantiated)
      • setStyle

        function setStyle(style)
        Sets the style of this column. This method only sets the given style as the default style for this column, without changing the style settings for existing cells in this column. To update style settings of existing cells to the specified style at the same time, please use applyStyle(com.aspose.cells.Style, com.aspose.cells.StyleFlag)
        Parameters:
        style: Style - the style to be used as the default style for cells in this column.