aspose.cells

Class ColumnCollection

Collection of the objects that represent the individual column(setting)s in a worksheet. The Column object only represents the settings such as column width, styles, .etc. for the whole column, has nothing to do with the fact that there are non-empty cells(data) or not in corresponding column. And the "Count" of this collection only represents the count Column objects that have been instantiated in this collection, has nothing to do with the fact that there are non-empty cells(data) or not in the worksheet.

Example:

//Instantiating a Workbook object
$workbook = new cells\Workbook();
//Obtaining the reference of the first worksheet
$worksheet = $workbook->getWorksheets()->get(0);
//Add new Style to Workbook
$style = $workbook->createStyle();
//Setting the background color to Blue
$style->setForegroundColor(cells\Color::getBlue());
//setting Background Pattern
$style->setPattern(cells\BackgroundType::SOLID);
//New Style Flag
$styleFlag = new cells\StyleFlag();
//Set All Styles
$styleFlag->setAll(true);

//Change the default width of first ten columns
for ($i = 0; $i < 10; $i++)
{
    $worksheet->getCells()->getColumns()->get($i)->setWidth(20);
}

//Get the Column with non default formatting
$columns = $worksheet->getCells()->getColumns();
for ($o = $columns->iterator(); java_values($o->hasNext());)
{
    $column = $o->next();
    echo "Apply style to column-".$column->getIndex()."\n";
    //Apply Style to first ten Columns
    $column->applyStyle($style, $styleFlag);
}
See Also:
Column

Property Getters/Setters Summary
functiongetCount()
functionget(columnIndex)
Gets a object by column index. The Column object of given column index will be instantiated if it does not exist before.
 
Method Summary
functionadd(value)
Reserved for internal use.
functionclear()
functioncontains(value)
Reserved for internal use.
functionget(index)
Reserved for internal use.
functiongetByIndex(index)
Gets the column object by the index.
functiongetColumnByIndex(index)
Gets the Column object by the position in the list.
functionindexOf(value)
Reserved for internal use.
functioniterator()
functionremoveAt(index)
 

    • Property Getters/Setters Detail

      • getCount : Number 

        function getCount()
        
      • get : Column 

        function get(columnIndex)
        
        Gets a object by column index. The Column object of given column index will be instantiated if it does not exist before.
        See Also:
        Column
    • Method Detail

      • getByIndex

        function getByIndex(index)
        Gets the column object by the index. NOTE: This member is now obsolete. Instead, please use Columns.GetColumnByIndex() method. This property will be removed 12 months later since June 2010. Aspose apologizes for any inconvenience you may have experienced.
        Parameters:
        index: Number -
        Returns:
        Returns the column object.
      • getColumnByIndex

        function getColumnByIndex(index)
        Gets the Column object by the position in the list.
        Parameters:
        index: Number - The position in the list.
        Returns:
        Returns the column object.
      • clear

        function clear()
      • removeAt

        function removeAt(index)
      • iterator

        function iterator()
      • get

        function get(index)
        Reserved for internal use.
      • contains

        function contains(value)
        Reserved for internal use.
      • add

        function add(value)
        Reserved for internal use.
      • indexOf

        function indexOf(value)
        Reserved for internal use.