Aspose::Cells::Column class

Column class

Represents a single column in a worksheet.

class Column

Methods

MethodDescription
ApplyStyle(const Style& style, const StyleFlag& flag)Applies formats for a whole column.
Column(Column_Impl* impl)Constructs from an implementation object.
Column(const Column& src)Copy constructor.
GetGroupLevel()Gets the group level of the column.
GetHasCustomStyle()Indicates whether this column has custom style settings(different from the default one inherited from workbook).
GetIndex()Gets the index of this column.
GetStyle()Gets the style of this column.
GetWidth()Gets and sets the column width in unit of characters.
IsCollapsed()whether the column is collapsed
IsHidden()Indicates whether the column is hidden.
IsNull() constChecks whether the implementation object is nullptr.
explicit operator bool() constoperator bool()
operator=(const Column& src)operator=
SetGroupLevel(uint8_t value)Gets the group level of the column.
SetIsCollapsed(bool value)whether the column is collapsed
SetIsHidden(bool value)Indicates whether the column is hidden.
SetStyle(const Style& style)Sets the style of this column.
SetWidth(double value)Gets and sets the column width in unit of characters.
~Column()Destructor.

Fields

FieldDescription
_implThe implementation object.

Examples

Aspose::Cells::Startup();
//Instantiating a Workbook object
Workbook workbook;

//Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
Style style = workbook.CreateStyle();

//Setting the background color to Blue
style.SetBackgroundColor(Color{ 0xff, 0, 0, 0xff });

//Setting the foreground color to Red
style.SetForegroundColor(Color{ 0xff, 0xff, 0, 0 });

//setting Background Pattern
style.SetPattern(BackgroundType::DiagonalStripe);

//New Style Flag
StyleFlag styleFlag;

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

//Get first Column
Column column = worksheet.GetCells().GetColumns().Get(0);

//Apply Style to first Column
column.ApplyStyle(style, styleFlag);

//Saving the Excel file
workbook.Save(u"book1.xls");

Aspose::Cells::Cleanup();

See Also