Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

Created Unassigned: Cell CachedFormulaResultType throws System.InvalidOperationException [13931]

$
0
0
Reading cell value from formula based cell using its CachedFormulaResultType throws InvalidOperationException with message "Only formula cells have cached results".

For test read only column A of attached sample file. The cell is part of array formula. First cell of range contains CachedFormulaResultType but all other cells throw exception.

Method for reading value

```
private static string GetCellValue(ICell cell, CellType cellType)
{
string cellValue = string.Empty;
switch (cellType)
{
case CellType.Blank:
break;
case CellType.Boolean:
cellValue = cell.BooleanCellValue.ToString();
break;
case CellType.Error:
cellValue = "error";
break;
case CellType.Formula:
cellValue = GetCellValue(cell, cell.CachedFormulaResultType);
break;
case CellType.Numeric:
if (DateUtil.IsCellDateFormatted(cell))
{
cellValue = cell.DateCellValue.ToString("yyyy-MM-ddTHH:mm:ss.fffK");
}
else
{
var n = (decimal) cell.NumericCellValue;
cellValue = n.ToString(CultureInfo.InvariantCulture);
}
break;
case CellType.String:
cellValue = cell.StringCellValue;
break;
case CellType.Unknown:
break;
default:
break;
}
return cellValue;
}

```

Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>