Class Column
Contents
[
Hide
]Column class
Represents a single column in a worksheet.
public class Column
Properties
Name | Description |
---|---|
GroupLevel { get; set; } | Gets the group level of the column. |
HasCustomStyle { get; } | Indicates whether this column has custom style settings(different from the default one inherited from workbook). |
Index { get; } | Gets the index of this column. |
IsCollapsed { get; set; } | whether the column is collapsed |
IsHidden { get; set; } | Indicates whether the column is hidden. |
Style { get; } | (Obsolete.) Gets the style of this column. |
Width { get; set; } | Gets and sets the column width in unit of characters. |
Methods
Name | Description |
---|---|
ApplyStyle(Style, StyleFlag) | Applies formats for a whole column. |
GetStyle() | Gets the style of this column. |
SetStyle(Style) | Sets the style of this column. |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using System;
using System.Drawing;
public class ColumnDemo
{
public static void ColumnExample()
{
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Obtaining the reference of the first worksheet
Worksheet worksheet = workbook.Worksheets[0];
// Add new Style to Workbook
Style style = workbook.CreateStyle();
// Setting the background color to Blue
style.BackgroundColor = Color.Blue;
// Setting the foreground color to Red
style.ForegroundColor = Color.Red;
// Setting Background Pattern
style.Pattern = BackgroundType.DiagonalStripe;
// New Style Flag
StyleFlag styleFlag = new StyleFlag();
// Set All Styles
styleFlag.All = true;
// Get first Column
Column column = worksheet.Cells.Columns[0];
// Apply Style to first Column
column.ApplyStyle(style, styleFlag);
// Setting additional properties
column.Width = 20.0; // Setting the column width
column.IsHidden = false; // Setting the column visibility
column.IsCollapsed = false; // Setting the column collapsed state
// Saving the Excel file
workbook.Save("ColumnExample.xlsx");
workbook.Save("ColumnExample.pdf");
}
}
}
See Also
- namespace Aspose.Cells
- assembly Aspose.Cells