Aspose::Cells::IColumnCollection Class Referenceabstract

Collects the IColumn objects that represent the individual columns in a worksheet. More...

Inherits CollectionBase.

Public Member Functions

virtual intrusive_ptr< Aspose::Cells::IColumnGetIColumn (Aspose::Cells::Systems::Int32 index)=0
 Gets the column object by the index. More...
 
virtual intrusive_ptr< Aspose::Cells::IColumnGetIColumnByIndex (Aspose::Cells::Systems::Int32 index)=0
 Gets the IColumn object by the position in the list. More...
 
virtual intrusive_ptr< Aspose::Cells::IColumnGetObjectByIndex (Aspose::Cells::Systems::Int32 columnIndex)=0
 Gets a IColumn object by column index. The Column object of given column index will be instantiated if it does not exist before. More...
 

Detailed Description

Collects the IColumn objects that represent the individual columns in a worksheet.

[C++]
//Instantiating a Workbook object
intrusive_ptr<IWorkbook> workbook = Factory::CreateIWorkbook();
//Obtaining the reference of the first worksheet
intrusive_ptr<IWorksheet> worksheet = workbook->GetIWorksheets()->GetObjectByIndex(0);
//Add new Style to Workbook
intrusive_ptr<IStyle> style = workbook->GetIStyles()->GetObjectByIndex(workbook->GetIStyles()->Add());
//Setting the background color to Blue
style->SetForegroundColor(Color::GetBlue());
//setting Background Pattern
style->SetPattern(BackgroundType::BackgroundType_Solid);
//New Style Flag
intrusive_ptr<IStyleFlag> styleFlag = Factory::CreateIStyleFlag();
//Set All Styles
styleFlag->SetAll(true);
//Change the default width of first ten columns
for (int i = 0; i< 10; i++)
{
worksheet->GetICells()->GetIColumns()->GetObjectByIndex(i)->SetWidth(20);
}
//Get the Column with non default formatting
intrusive_ptr<IColumnCollection> columns = worksheet->GetICells()->GetIColumns();
for (intrusive_ptr<Aspose::Cells::Systems::Collections::IEnumerator> iter = columns->GetEnumerator(); iter->MoveNext();)
{
//Apply Style to first ten Columns
intrusive_ptr<Aspose::Cells::IColumn> column = dynamic_pointer_cast<Aspose::Cells::IColumn>(iter->GetCurrent());
column->ApplyStyle(style, styleFlag);
}
//Saving the Excel file
workbook->Save(new String("D:\\book1.xls"));

Member Function Documentation

◆ GetIColumn()

virtual intrusive_ptr<Aspose::Cells::IColumn> Aspose::Cells::IColumnCollection::GetIColumn ( Aspose::Cells::Systems::Int32  index)
pure virtual

Gets the column object by the index.

Parameters
index
Returns
Returns the column object.

NOTE: This member is now obsolete. Instead, please use GetIColumnByIndex(int) method.

◆ GetIColumnByIndex()

virtual intrusive_ptr<Aspose::Cells::IColumn> Aspose::Cells::IColumnCollection::GetIColumnByIndex ( Aspose::Cells::Systems::Int32  index)
pure virtual

Gets the IColumn object by the position in the list.

Parameters
indexThe position in the list.
Returns
Returns the column object.

◆ GetObjectByIndex()

virtual intrusive_ptr<Aspose::Cells::IColumn> Aspose::Cells::IColumnCollection::GetObjectByIndex ( Aspose::Cells::Systems::Int32  columnIndex)
pure virtual

Gets a IColumn object by column index. The Column object of given column index will be instantiated if it does not exist before.