private static void SetCellType(NPOI.SS.UserModel.Cell cell, NPOI.SS.UserModel.CellValue cv) { NPOI.SS.UserModel.CellType cellType = cv.CellType; switch (cellType) { case NPOI.SS.UserModel.CellType.BOOLEAN: case NPOI.SS.UserModel.CellType.ERROR: case NPOI.SS.UserModel.CellType.NUMERIC: case NPOI.SS.UserModel.CellType.STRING: cell.SetCellType(cellType); return; case NPOI.SS.UserModel.CellType.BLANK: // never happens - blanks eventually get translated to zero break; case NPOI.SS.UserModel.CellType.FORMULA: // this will never happen, we have already evaluated the formula break; } throw new InvalidOperationException("Unexpected cell value type (" + cellType + ")"); }