private static void SetCellValue(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: cell.SetCellValue(cv.BooleanValue); break; case NPOI.SS.UserModel.CellType.ERROR: cell.CellErrorValue=cv.ErrorValue; break; case NPOI.SS.UserModel.CellType.NUMERIC: cell.SetCellValue(cv.NumberValue); break; case NPOI.SS.UserModel.CellType.STRING: cell.SetCellValue(new HSSFRichTextString(cv.StringValue)); break; //case NPOI.SS.UserModel.CellType.BLANK: //// never happens - blanks eventually get translated to zero //case NPOI.SS.UserModel.CellType.FORMULA: //// this will never happen, we have already evaluated the formula default: throw new InvalidOperationException("Unexpected cell value type (" + cellType + ")"); } }