NativeExcel2 for .NET Developer's Reference

Referring to Ranges using A1 notation

You can refer to a range of cells in the A1 reference style by using the Range or Cells property.

Example

This example demonstrates how to reference range A1:D5.

[C#]
//variant 1 
book.Worksheets[1].Range["A1","D5"].Font.Bold = true;
//variant 2 
book.Worksheets[1].Range["A1:D5"].Font.Bold = true;
//variant 3 
book.Worksheets[1].Cells["A1","D5"].Font.Bold = true;
//variant 4 
book.Worksheets[1].Cells["A1:D5"].Font.Bold = true;
        
[Visual Basic]
'variant 1 
book.Worksheets(1).Range("A1","D5").Font.Bold = True
'variant 2 
book.Worksheets(1).Range("A1:D5").Font.Bold = True
'variant 3 
book.Worksheets(1).Cells("A1","D5").Font.Bold = True
'variant 4 
book.Worksheets(1).Cells("A1:D5").Font.Bold = True
        
[C++]
//variant 1 
book->Worksheets->Item[1]->Range->Item[S"A1",S"D5"]->Font->Bold = true;
//variant 2 
book->Worksheets->Item[1]->Range->Item[S"A1:D5"]->Font->Bold = true;
//variant 3 
book->Worksheets->Item[1]->Cells->Item[S"A1",S"D5"]->Font->Bold = true;
//variant 4 
book->Worksheets->Item[1]->Cells->Item[S"A1:D5"]->Font->Bold = true;
        

See also

IRange.Item[string] Property | IRange.Item[string, string] Property