Exemplo n.º 1
0
        /**
         * Use this to create new cells within the row and return it.
         *
         * @param columnIndex - the column number this cell represents
         * @param type - the cell's data type
         * @return XSSFCell a high level representation of the Created cell.
         * @throws ArgumentException if the specified cell type is invalid, columnIndex < 0
         *   or greater than 16384, the maximum number of columns supported by the SpreadsheetML format (.xlsx)
         * @see Cell#CELL_TYPE_BLANK
         * @see Cell#CELL_TYPE_BOOLEAN
         * @see Cell#CELL_TYPE_ERROR
         * @see Cell#CELL_TYPE_FORMULA
         * @see Cell#CELL_TYPE_NUMERIC
         * @see Cell#CELL_TYPE_STRING
         */
        public ICell CreateCell(int columnIndex, CellType type)
        {
            CT_Cell  ctCell;
            XSSFCell prev = _cells.ContainsKey(columnIndex) ? (XSSFCell)_cells[columnIndex] : null;

            if (prev != null)
            {
                ctCell = prev.GetCTCell();
                ctCell.Set(new CT_Cell());
            }
            else
            {
                ctCell = _row.AddNewC();
            }

            int style = _sheet.GetColDefaultStyle(columnIndex);

            if (style >= 0)
            {
                ctCell.s = (uint)style;
            }

            XSSFCell xcell = new XSSFCell(this, ctCell);

            xcell.SetCellNum(columnIndex);
            if (type != CellType.Blank)
            {
                xcell.SetCellType(type);
            }

            _cells[columnIndex] = xcell;
            return(xcell);
        }
Exemplo n.º 2
0
        /**
         * Use this to create new cells within the row and return it.
         *
         * @param columnIndex - the column number this cell represents
         * @param type - the cell's data type
         * @return XSSFCell a high level representation of the Created cell.
         * @throws ArgumentException if the specified cell type is invalid, columnIndex < 0
         *   or greater than 16384, the maximum number of columns supported by the SpreadsheetML format (.xlsx)
         * @see Cell#CELL_TYPE_BLANK
         * @see Cell#CELL_TYPE_BOOLEAN
         * @see Cell#CELL_TYPE_ERROR
         * @see Cell#CELL_TYPE_FORMULA
         * @see Cell#CELL_TYPE_NUMERIC
         * @see Cell#CELL_TYPE_STRING
         */
        public ICell CreateCell(int columnIndex, CellType type)
        {
            CT_Cell  ctCell;
            XSSFCell prev = _cells.ContainsKey(columnIndex) ? (XSSFCell)_cells[columnIndex] : null;

            if (prev != null)
            {
                ctCell = prev.GetCTCell();
                ctCell.Set(new CT_Cell());
            }
            else
            {
                ctCell = _row.AddNewC();
            }
            XSSFCell xcell = new XSSFCell(this, ctCell);

            xcell.SetCellNum(columnIndex);
            if (type != CellType.BLANK)
            {
                xcell.SetCellType(type);
            }
            _cells[columnIndex] = xcell;
            return(xcell);
        }
Exemplo n.º 3
0
        public ICell CreateCell(int columnIndex, CellType type)
        {
            XSSFCell xssfCell1 = this._cells.ContainsKey(columnIndex) ? (XSSFCell)this._cells[columnIndex] : (XSSFCell)null;
            CT_Cell  cell;

            if (xssfCell1 != null)
            {
                cell = xssfCell1.GetCTCell();
                cell.Set(new CT_Cell());
            }
            else
            {
                cell = this._row.AddNewC();
            }
            XSSFCell xssfCell2 = new XSSFCell(this, cell);

            xssfCell2.SetCellNum(columnIndex);
            if (type != CellType.BLANK)
            {
                xssfCell2.SetCellType(type);
            }
            this._cells[columnIndex] = (ICell)xssfCell2;
            return((ICell)xssfCell2);
        }