/// <summary> /// Create a high level Cell object from an existing low level record. Should /// only be called from HSSFSheet or HSSFRow itself. /// </summary> /// <param name="cell">The low level cell to Create the high level representation from</param> /// <returns> the low level record passed in</returns> public ICell CreateCellFromRecord(CellValueRecordInterface cell) { ICell hcell = new HSSFCell(book, sheet, cell); AddCell(hcell); int colIx = cell.Column; if (row.IsEmpty) { row.FirstCol=(colIx); row.LastCol=(colIx + 1); } else { if (colIx < row.FirstCol) { row.FirstCol = (colIx); } else if (colIx > row.LastCol) { row.LastCol = (colIx + 1); } else { // added cell is within first and last cells } } // TODO - RowRecord column boundaries need to be updated for cell comments too return hcell; }
/// <summary> /// Use this to create new cells within the row and return it. /// The cell that is returned is a CELL_TYPE_BLANK. The type can be changed /// either through calling setCellValue or setCellType. /// </summary> /// <param name="columnIndex">the column number this cell represents</param> /// <param name="type">a high level representation of the created cell.</param> /// <returns></returns> public ICell CreateCell(int columnIndex, CellType type) { short shortCellNum = (short)columnIndex; if (columnIndex > 0x7FFF) { shortCellNum = (short)(0xffff - columnIndex); } ICell cell = new HSSFCell(book, sheet, RowNum, (short)columnIndex, type); AddCell(cell); sheet.Sheet.AddValueRecord(RowNum, ((HSSFCell)cell).CellValueRecord); return cell; }