Пример #1
0
        /**
         * Adds a cell to this row, growing the array of cells as required
         *
         * @param cv the cell to add
         */
        public void addCell(CellValue cv)
        {
            int col = cv.getColumn();

            if (col >= maxColumns)
            {
                //logger.warn("Could not add cell at " +
                //            CellReferenceHelper.getCellReference(cv.getRow(),
                //                                                 cv.getColumn()) +
                //            " because it exceeds the maximum column limit");
                return;
            }

            // Grow the array if needs be
            if (col >= cells.Length)
            {
                CellValue[] oldCells = cells;
                cells = new CellValue[System.Math.Max(oldCells.Length + growSize, col + 1)];
                System.Array.Copy(oldCells, 0, cells, 0, oldCells.Length);
                oldCells = null;
            }

            // Remove any cell features from the cell being replaced
            if (cells[col] != null)
            {
                WritableCellFeatures wcf = cells[col].getWritableCellFeatures();
                if (wcf != null)
                {
                    wcf.removeComment();

                    // if the cell is part of a shared data validation,then don't remove
                    // the validation
                    if (wcf.getDVParser() != null &&
                        !wcf.getDVParser().extendedCellsValidation())
                    {
                        wcf.removeDataValidation();
                    }
                }
            }

            cells[col] = cv;

            numColumns = System.Math.Max(col + 1, numColumns);
        }
Пример #2
0
        /**
         * Sets the cell features
         *
         * @param cf the cell features
         */
        public void setCellFeatures(WritableCellFeatures cf)
        {
            if (features != null)
            {
                //logger.warn("current cell features for " +
                //            CellReferenceHelper.getCellReference(this) +
                //            " not null - overwriting");

                // Check to see if the features include a shared data validation
                if (features.hasDataValidation() &&
                    features.getDVParser() != null &&
                    features.getDVParser().extendedCellsValidation())
                {
                    DVParser dvp = features.getDVParser();
                    //logger.warn("Cannot add cell features to " +
                    //            CellReferenceHelper.getCellReference(this) +
                    //            " because it is part of the shared cell validation " +
                    //            "group " +
                    //            CellReferenceHelper.getCellReference(dvp.getFirstColumn(),
                    //                                                 dvp.getFirstRow()) +
                    //            "-" +
                    //            CellReferenceHelper.getCellReference(dvp.getLastColumn(),
                    //                                                 dvp.getLastRow()));
                    return;
                }
            }

            features = cf;
            cf.setWritableCell(this);

            // If the cell is already on the worksheet, then add the cell features
            // to the workbook
            if (referenced)
            {
                addCellFeatures();
            }
        }