Formatting a Range of Cells

Setting Font & Style of a Range of Cells

Before we talk about formatting settings (which we have already discussed extensively in our previous topics), we should know how to create a range of cells. We can create a range of cells using the CellRange class, whose constructor takes parameters to specify the range of cells. We can specify the cell range using the Names or Row & Column Indices of the start and end cells.

Once we have created a CellRange object, we can use the overloaded versions of SetStyle, SetFont, and SetFontColor methods of Worksheet that accept a CellRange object to apply formatting settings to the specified range of cells.

Let’s check out an example to understand this basic concept.