Format and Modify Named Ranges

Format Ranges

How to Set Background Color and Font Attributes to a Named Range

To apply formatting, define a Style object to specify the style settings and apply it to the Range object.

The following example shows how to set the solid fill color (shading color) with font settings to a range.

How to Add Borders to a Named Range

It is possible to add borders to a range of cells instead of just a single cell. The Range object provides a set_outline_border method that takes the following parameters to add a border to the range of cells:

  • Border type, the type of border, selected from the BorderType enumeration.
  • Line style, the line style, selected from the CellBorderType enumeration.
  • Color, the line color, selected from the Color enumeration.

The following example shows how to set an outline border to a range.

How to Rename a Named Range

Aspose.Cells allows you to rename a named range for your need. You may get the named range and rename it by using Name.text attribute. The following example shows how to rename a named range.

How to Take Union of Ranges

Aspose.Cells provides Range.union method to take the union for ranges. The following example shows how to take union for ranges.

How to Intersect the Ranges

Aspose.Cells provides the Range.intersect method to intersect two ranges. The method returns a Range object. To check whether a range intersects another range, use the Range.intersect method that returns a Boolean value. The following example shows how to intersect the ranges.

How to Merge Cells in the Named Range

Aspose.Cells provides Range.merge() method to merge the cells in the range. The following example shows how to merge the individual cells of a named range.