Class UnionRange

UnionRange class

Represents union range.

public class UnionRange : IEnumerable

Properties

NameDescription
CellCount { get; }Gets all cell count in the range.
ColumnCount { get; }Gets the count of rows in the range.
FirstColumn { get; }Gets the index of the first column of the range.
FirstRow { get; }Gets the index of the first row of the range.
HasRange { get; }Indicates whether this has range.
Hyperlinks { get; }Gets all hyperlink in the range.
Name { get; set; }Gets or sets the name of the range.
RangeCount { get; }Gets the count of the ranges.
Ranges { get; }Gets all union ranges.
RefersTo { get; }Gets the range’s refers to.
RowCount { get; }Gets the count of rows in the range.
Value { get; set; }Gets and sets the values of the range.

Methods

NameDescription
ApplyStyle(Style, StyleFlag)Applies formats for a whole range.
Copy(UnionRange, PasteOptions)Copying the range with paste special options.
GetEnumerator()Gets the enumerator for cells in this Range.
Intersect(Range[])Intersects another range.
Intersect(string)Intersects another range.
Intersect(UnionRange)Intersects another range.
Merge()Combines a range of cells into a single cell.
PutValue(string, bool, bool)Puts a value into the range, if appropriate the value will be converted to other data type and cell’s number format will be reset.
SetOutlineBorders(CellBorderType, Color)Sets the outline borders around a range of cells with same border style and color.
SetOutlineBorders(CellBorderType[], Color[])Sets out line borders around a range of cells.
SetStyle(Style)Sets the style of the range.
Union(Range[])Union the ranges.
Union(string)Union another range.
Union(UnionRange)Union another range.
UnMerge()Unmerges merged cells of this range.

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class CellsClassUnionRangeDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            
            // Create a union range using the correct API
            UnionRange unionRange = workbook.Worksheets.CreateUnionRange("A1:A10,C1:C10", 0);
            
            // Set value for the entire union range
            unionRange.Value = "Test";
            
            // Apply style to the union range
            Style style = workbook.CreateStyle();
            style.Pattern = BackgroundType.Solid;
            style.ForegroundColor = System.Drawing.Color.LightBlue;
            unionRange.ApplyStyle(style, new StyleFlag { All = true });
            
            // Save the workbook
            workbook.Save("UnionRangeDemo.xlsx");
        }
    }
}

See Also