private static void SetCellValue(ICell cell, CellValue cv) { CellType cellType = cv.CellType; switch (cellType) { case CellType.BOOLEAN: cell.SetCellValue(cv.BooleanValue); break; case CellType.ERROR: cell.SetCellErrorValue((byte)cv.ErrorValue); break; case CellType.NUMERIC: cell.SetCellValue(cv.NumberValue); break; case CellType.STRING: cell.SetCellValue(new HSSFRichTextString(cv.StringValue)); break; //case CellType.BLANK: //// never happens - blanks eventually get translated to zero //case CellType.FORMULA: //// this will never happen, we have already evaluated the formula default: throw new InvalidOperationException("Unexpected cell value type (" + cellType + ")"); } }
private static void SetCellType(ICell cell, CellValue cv) { CellType cellType = cv.CellType; switch (cellType) { case CellType.BOOLEAN: case CellType.ERROR: case CellType.NUMERIC: case CellType.STRING: cell.SetCellType(cellType); return; case CellType.BLANK: // never happens - blanks eventually get translated to zero break; case CellType.FORMULA: // this will never happen, we have already evaluated the formula break; } throw new InvalidOperationException("Unexpected cell value type (" + cellType + ")"); }