Access and Modify Cell Value

Accessing & Modifying a Cell’s Value

String Values

Before accessing and modifying the value of a cell, you need to know how to access cells. For details about the different approaches for accessing cells, refer to Access Worksheet Cells.

Each cell has a property named StringValue. Once a cell is accessed, developers can use the StringValue property to access the cell’s string value. To modify cell values, a special method PutValue is provided, which can be used to update the cell’s string value.

All Types of Values

The PutValue method of a cell object has eight overloads available, which can be used to modify any type of value (Boolean, int, double, DateTime, and string) in a cell.

There is also an overloaded version of the PutValue method that can take any kind of value in string format and convert it to a proper data type automatically. To make it happen, pass the Boolean value true to an additional parameter of the PutValue method as shown below in the example.