NativeExcel for .NET Developer's Reference

Referring to Cells using A1 notation

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

Example

This example demonstrates how to reference a single cell.

[C#]
//variant 1   
book.Worksheets[1].Range["B3"].Value = 100;
//variant 2   
book.Worksheets[1].Range["B3:B3"].Value = 100;
//variant 3   
book.Worksheets[1].Range["B3","B3"].Value = 100;
//variant 4   
book.Worksheets[1].Cells["B3"].Value = 100;
//variant 5   
book.Worksheets[1].Cells["B3:B3"].Value = 100;
//variant 6   
book.Worksheets[1].Cells["B3","B3"].Value = 100;
        
[Visual Basic]
'variant 1   
book.Worksheets(1).Range("B3").Value = 100
'variant 2   
book.Worksheets(1).Range("B3:B3").Value = 100
'variant 3   
book.Worksheets(1).Range("B3","B3").Value = 100
'variant 4   
book.Worksheets(1).Cells("B3").Value = 100
'variant 5   
book.Worksheets(1).Cells("B3:B3").Value = 100
'variant 6   
book.Worksheets(1).Cells("B3","B3").Value = 100
        
[C++]
//variant 1   
book->Worksheets->Item[1]->Range->Item[S"B3"]->Value = 100;
//variant 2   
book->Worksheets->Item[1]->Range->Item[S"B3:B3"]->Value = 100;
//variant 3   
book->Worksheets->Item[1]->Range->Item[S"B3",S"B3"]->Value = 100;
//variant 4   
book->Worksheets->Item[1]->Cells->Item[S"B3"]->Value = 100;
//variant 5   
book->Worksheets->Item[1]->Cells->Item[S"B3:B3"]->Value = 100;
//variant 6   
book->Worksheets->Item[1]->Cells->Item[S"B3",S"B3"]->Value = 100;
        

See also

IRange.Item[string] Property