public ICell GetCell(int cellnum, MissingCellPolicy policy) { CheckBounds(cellnum); SXSSFCell cell = null; if (_cells.ContainsKey(cellnum)) { cell = _cells[cellnum]; } switch (policy) { case MissingCellPolicy.RETURN_NULL_AND_BLANK: return(cell); case MissingCellPolicy.RETURN_BLANK_AS_NULL: bool isBlank = (cell != null && cell.CellType == CellType.Blank); return((isBlank) ? null : cell); case MissingCellPolicy.CREATE_NULL_AS_BLANK: return((cell == null) ? CreateCell(cellnum, CellType.Blank) : cell); default: throw new ArgumentException("Illegal policy " + policy + " (" + policy + ")"); } }
/** * Returns the cell at the given (0 based) index, with the specified {@link NPOI.SS.usermodel.Row.MissingCellPolicy} * * @return the cell at the given (0 based) index * @throws ArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid * @see Row#RETURN_NULL_AND_BLANK * @see Row#RETURN_BLANK_AS_NULL * @see Row#CREATE_NULL_AS_BLANK */ public ICell GetCell(int cellnum, MissingCellPolicy policy) { if (cellnum < 0) { throw new ArgumentException("Cell index must be >= 0"); } XSSFCell cell = (XSSFCell)RetrieveCell(cellnum); if (policy == MissingCellPolicy.RETURN_NULL_AND_BLANK) { return(cell); } if (policy == MissingCellPolicy.RETURN_BLANK_AS_NULL) { if (cell == null) { return(cell); } if (cell.CellType == CellType.BLANK) { return(null); } return(cell); } if (policy == MissingCellPolicy.CREATE_NULL_AS_BLANK) { if (cell == null) { return(CreateCell(cellnum, CellType.BLANK)); } return(cell); } throw new ArgumentException("Illegal policy " + policy + " (" + policy.id + ")"); }
/** * Returns the cell at the given (0 based) index, with the specified {@link NPOI.SS.usermodel.Row.MissingCellPolicy} * * @return the cell at the given (0 based) index * @throws ArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid * @see Row#RETURN_NULL_AND_BLANK * @see Row#RETURN_BLANK_AS_NULL * @see Row#CREATE_NULL_AS_BLANK */ public ICell GetCell(int cellnum, MissingCellPolicy policy) { if (cellnum < 0) { throw new ArgumentException("Cell index must be >= 0"); } XSSFCell cell = (XSSFCell)RetrieveCell(cellnum); switch (policy) { case MissingCellPolicy.RETURN_NULL_AND_BLANK: return(cell); case MissingCellPolicy.RETURN_BLANK_AS_NULL: bool isBlank = (cell != null && cell.CellType == CellType.Blank); return((isBlank) ? null : cell); case MissingCellPolicy.CREATE_NULL_AS_BLANK: return((cell == null) ? CreateCell(cellnum, CellType.Blank) : cell); default: throw new ArgumentException("Illegal policy " + policy + " (" + policy + ")"); } }
/// <summary> /// Get the hssfcell representing a given column (logical cell) /// 0-based. If you ask for a cell that is not defined, then /// your supplied policy says what to do /// </summary> /// <param name="cellnum">0 based column number</param> /// <param name="policy">Policy on blank / missing cells</param> /// <returns>that column or null if Undefined + policy allows.</returns> public Cell GetCell(int cellnum, MissingCellPolicy policy) { NPOI.SS.UserModel.Cell cell = RetrieveCell(cellnum); if (policy == MissingCellPolicy.RETURN_NULL_AND_BLANK) { return(cell); } if (policy == MissingCellPolicy.RETURN_BLANK_AS_NULL) { if (cell == null) { return(cell); } if (cell.CellType == NPOI.SS.UserModel.CellType.BLANK) { return(null); } return(cell); } if (policy == MissingCellPolicy.CREATE_NULL_AS_BLANK) { if (cell == null) { return(CreateCell((short)cellnum, NPOI.SS.UserModel.CellType.BLANK)); } return(cell); } throw new ArgumentException("Illegal policy " + policy + " (" + policy.id + ")"); }
public ICell GetCell(int cellnum, MissingCellPolicy policy) { CheckBounds(cellnum); var cell = _cells[cellnum]; switch (policy._policy) { case MissingCellPolicy.Policy.RETURN_NULL_AND_BLANK: return(cell); case MissingCellPolicy.Policy.RETURN_BLANK_AS_NULL: bool isBlank = (cell != null && cell.CellType == CellType.Blank); return((isBlank) ? null : cell); case MissingCellPolicy.Policy.CREATE_NULL_AS_BLANK: return((cell == null) ? CreateCell(cellnum, CellType.Blank) : cell); default: throw new InvalidOperationException("Illegal policy " + policy + " (" + policy.id + ")"); } }
public ICell GetCell(int cellnum, MissingCellPolicy policy) { return(_row.GetCell(cellnum, policy)); }
/// <summary> /// Get the hssfcell representing a given column (logical cell) /// 0-based. If you ask for a cell that is not defined, then /// your supplied policy says what to do /// </summary> /// <param name="cellnum">0 based column number</param> /// <param name="policy">Policy on blank / missing cells</param> /// <returns>that column or null if Undefined + policy allows.</returns> public ICell GetCell(int cellnum, MissingCellPolicy policy) { ICell cell = RetrieveCell(cellnum); if (policy == MissingCellPolicy.RETURN_NULL_AND_BLANK) { return cell; } if (policy == MissingCellPolicy.RETURN_BLANK_AS_NULL) { if (cell == null) return cell; if (cell.CellType == CellType.Blank) { return null; } return cell; } if (policy == MissingCellPolicy.CREATE_NULL_AS_BLANK) { if (cell == null) { return CreateCell(cellnum, CellType.Blank); } return cell; } throw new ArgumentException("Illegal policy " + policy + " (" + policy.id + ")"); }