com.aspose.cells

Class ColumnCollection

  • All Implemented Interfaces:
    java.lang.Iterable
    public class ColumnCollection 
    extends CollectionBase

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

Example:

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);

//Add new Style to Workbook
Style style = workbook.getStyles().get(workbook.getStyles().add());

//Setting the background color to Blue
style.setForegroundColor(Color.getBlue());

//setting Background Pattern
style.setPattern(BackgroundType.SOLID);

//New Style Flag
StyleFlag styleFlag = new StyleFlag();

//Set All Styles
styleFlag.setAll(true);

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

//Get the Column with non default formatting
ColumnCollection columns = worksheet.getCells().getColumns();

for (Column column : (Iterable<Column>) columns)
{
    //Apply Style to first ten Columns
    column.applyStyle(style, styleFlag);
}

//Saving the Excel file
workbook.save("D:\\book1.xls");
See Also:
Column

Property Getters/Setters Summary
intgetCount()
Columnget(intcolumnIndex)
Gets a object by column index. The Column object of given column index will be instantiated if it does not exist before.
 
Method Summary
intadd(java.lang.Objectvalue)
Reserved for internal use.
voidclear()
booleancontains(java.lang.Objectvalue)
Reserved for internal use.
java.lang.Objectget(intindex)
Reserved for internal use.
ColumngetByIndex(intindex)
Gets the column object by the index.
ColumngetColumnByIndex(intindex)
Gets the Column object by the position in the list.
intindexOf(java.lang.Objectvalue)
Reserved for internal use.
java.util.Iteratoriterator()
voidremoveAt(intindex)
 

    • Property Getters/Setters Detail

      • getCount

        public int getCount()
        
      • get

        public Column get(int 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

        public Column getByIndex(int 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 -
        Returns:
        Returns the column object.
      • getColumnByIndex

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

        public void clear()
      • removeAt

        public void removeAt(int index)
      • iterator

        public java.util.Iterator iterator()
      • get

        public java.lang.Object get(int index)
        Reserved for internal use.
      • contains

        public boolean contains(java.lang.Object value)
        Reserved for internal use.
      • add

        public int add(java.lang.Object value)
        Reserved for internal use.
      • indexOf

        public int indexOf(java.lang.Object value)
        Reserved for internal use.