Format and Modify Named Ranges with Golang via C++

Format Ranges

Setting 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.

Adding 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 SetOutlineBorder 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.

The following example shows how to set borders around each cell in the range.

Rename a Named Range

Aspose.Cells allows you to rename a named range to suit your needs. You may get the named range and rename it by using the Name.SetText() method. The following example shows how to rename a named range.

Union of Ranges

Aspose.Cells provides the Range.UnionRange method to take the union of ranges; the method returns a std::vector object. The following example shows how to take the union of ranges.

Intersection of 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.IsIntersect method, which returns a Boolean value. The following example shows how to intersect the ranges.

Merge Cells in the Named Range

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

Remove a Named Range

Aspose.Cells provides the NameCollection.RemoveAt() method to erase the name of the range. To clear the contents of the range, use the Cells.ClearRange() method. The following example shows how to remove a named range along with its contents.