A cell can contain a value and/or a formula. To check if a cell is empty use the Cell.Value and Cell.Formula properties to look for the following conditions:
| Language |
Cell.Value |
Cell.Formula |
| C# |
null |
(empty string) |
| VB.NET |
Nothing |
Nothing |
| Java |
null |
(empty string) |
| ASP/COM * |
(empty string) |
(empty string) |
* Includes SAExcelApplicationDotNet wrapper class used in ASP.NET
Examples
The following examples demonstrate how to check if a cell is empty:
|
[C#]
|
[VB.NET]
|
[Java]
|
[COM/ASP]
|
|
//--- myCell is a Cell object
if (myCell.Value == null && myCell.Formula == "")
{
//--- Cell is empty
}
'--- myCell is a Cell object
If (myCell.Value = Nothing And myCell.Formula = Nothing) Then
'--- Cell is empty
End If
//--- myCell is a Cell object
if (myCell.getValue() == null && myCell.getFormula().equals(""))
{
//--- Cell is empty
}
'--- myCell is an SACell object
If (myCell.Value = "" And myCell.Formula = "") Then
'--- Cell is empty
End If
|
|