@Override public boolean isPartOfArrayFormulaGroup() { return _cell.isPartOfArrayFormulaGroup(); }
private void notifyRowShifting(HSSFRow row) { String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for (Cell cell : row) { HSSFCell hcell = (HSSFCell) cell; if (hcell.isPartOfArrayFormulaGroup()) { hcell.notifyArrayFormulaChanging(msg); } } }
if (xcell.isPartOfArrayFormulaGroup()) { String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. You cannot change part of an array."; xcell.notifyArrayFormulaChanging(msg);
/** * Set the cells type (numeric, formula or string). * If the cell currently contains a value, the value will * be converted to match the new type, if possible. */ @Override public void setCellType(CellType cellType) { notifyFormulaChanging(); if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); } int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); setCellType(cellType, true, row, col, styleIndex); }
private void validateArrayFormulas(CellRangeAddress region) { // FIXME: this may be faster if it looped over array formulas directly rather than looping over each cell in // the region and searching if that cell belongs to an array formula int firstRow = region.getFirstRow(); int firstColumn = region.getFirstColumn(); int lastRow = region.getLastRow(); int lastColumn = region.getLastColumn(); for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) { HSSFRow row = getRow(rowIn); if (row == null) continue; for (int colIn = firstColumn; colIn <= lastColumn; colIn++) { HSSFCell cell = row.getCell(colIn); if (cell == null) continue; if (cell.isPartOfArrayFormulaGroup()) { CellRangeAddress arrayRange = cell.getArrayFormulaRange(); if (arrayRange.getNumberOfCells() > 1 && region.intersects(arrayRange)) { String msg = "The range " + region.formatAsString() + " intersects with a multi-cell array formula. " + "You cannot merge cells of an array."; throw new IllegalStateException(msg); } } } } }
private void removeCell(HSSFCell cell, boolean alsoRemoveRecords) { int column=cell.getColumnIndex(); if(column < 0) { throw new RuntimeException("Negative cell indexes not allowed"); } if(column >= cells.length || cell != cells[column]) { throw new RuntimeException("Specified cell is not from this row"); } if(cell.isPartOfArrayFormulaGroup()){ cell.notifyArrayFormulaChanging(); } cells[column]=null; if(alsoRemoveRecords) { CellValueRecordInterface cval = cell.getCellValueRecord(); sheet.getSheet().removeValueRecord(getRowNum(), cval); } if (cell.getColumnIndex()+1 == row.getLastCol()) { row.setLastCol(calculateNewLastCellPlusOne(row.getLastCol())); } if (cell.getColumnIndex() == row.getFirstCol()) { row.setFirstCol(calculateNewFirstCell(row.getFirstCol())); } }
public void setCellFormula(String formula) { if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); } int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); if (formula==null) { notifyFormulaChanging(); setCellType(CellType.BLANK, false, row, col, styleIndex); return; } int sheetIndex = _book.getSheetIndex(_sheet); Ptg[] ptgs = HSSFFormulaParser.parse(formula, _book, FormulaType.CELL, sheetIndex); setCellType(CellType.FORMULA, false, row, col, styleIndex); FormulaRecordAggregate agg = (FormulaRecordAggregate) _record; FormulaRecord frec = agg.getFormulaRecord(); frec.setOptions((short) 2); frec.setValue(0); //only set to default if there is no extended format index already set if (agg.getXFIndex() == (short)0) { agg.setXFIndex((short) 0x0f); } agg.setParsedExpression(ptgs); } /**
@Override public boolean isPartOfArrayFormulaGroup() { return _cell.isPartOfArrayFormulaGroup(); }
private void notifyRowShifting(HSSFRow row) { String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for (Cell cell : row) { HSSFCell hcell = (HSSFCell) cell; if (hcell.isPartOfArrayFormulaGroup()) { hcell.notifyArrayFormulaChanging(msg); } } }
private void notifyRowShifting(HSSFRow row){ String msg = "Row[rownum="+row.getRowNum()+"] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for(Cell cell : row){ HSSFCell hcell = (HSSFCell)cell; if(hcell.isPartOfArrayFormulaGroup()){ hcell.notifyArrayFormulaChanging(msg); } } }
private void notifyRowShifting(HSSFRow row) { String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for (Cell cell : row) { HSSFCell hcell = (HSSFCell) cell; if (hcell.isPartOfArrayFormulaGroup()) { hcell.notifyArrayFormulaChanging(msg); } } }
/** * Set the cells type (numeric, formula or string). * If the cell currently contains a value, the value will * be converted to match the new type, if possible. */ @Override public void setCellType(CellType cellType) { notifyFormulaChanging(); if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); } int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); setCellType(cellType, true, row, col, styleIndex); }
/** * set the cells type (numeric, formula or string) * @see #CELL_TYPE_NUMERIC * @see #CELL_TYPE_STRING * @see #CELL_TYPE_FORMULA * @see #CELL_TYPE_BLANK * @see #CELL_TYPE_BOOLEAN * @see #CELL_TYPE_ERROR */ public void setCellType(int cellType) { notifyFormulaChanging(); if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); } int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); setCellType(cellType, true, row, col, styleIndex); }
/** * set the cells type (numeric, formula or string) * @see #CELL_TYPE_NUMERIC * @see #CELL_TYPE_STRING * @see #CELL_TYPE_FORMULA * @see #CELL_TYPE_BLANK * @see #CELL_TYPE_BOOLEAN * @see #CELL_TYPE_ERROR */ public void setCellType(int cellType) { notifyFormulaChanging(); if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); } int row=_record.getRow(); short col=_record.getColumn(); short styleIndex=_record.getXFIndex(); setCellType(cellType, true, row, col, styleIndex); }
private void validateArrayFormulas(CellRangeAddress region) { // FIXME: this may be faster if it looped over array formulas directly rather than looping over each cell in // the region and searching if that cell belongs to an array formula int firstRow = region.getFirstRow(); int firstColumn = region.getFirstColumn(); int lastRow = region.getLastRow(); int lastColumn = region.getLastColumn(); for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) { HSSFRow row = getRow(rowIn); if (row == null) continue; for (int colIn = firstColumn; colIn <= lastColumn; colIn++) { HSSFCell cell = row.getCell(colIn); if (cell == null) continue; if (cell.isPartOfArrayFormulaGroup()) { CellRangeAddress arrayRange = cell.getArrayFormulaRange(); if (arrayRange.getNumberOfCells() > 1 && region.intersects(arrayRange)) { String msg = "The range " + region.formatAsString() + " intersects with a multi-cell array formula. " + "You cannot merge cells of an array."; throw new IllegalStateException(msg); } } } } }
private void removeCell(HSSFCell cell, boolean alsoRemoveRecords) { int column=cell.getColumnIndex(); if(column < 0) { throw new RuntimeException("Negative cell indexes not allowed"); } if(column >= cells.length || cell != cells[column]) { throw new RuntimeException("Specified cell is not from this row"); } if(cell.isPartOfArrayFormulaGroup()){ cell.notifyArrayFormulaChanging(); } cells[column]=null; if(alsoRemoveRecords) { CellValueRecordInterface cval = cell.getCellValueRecord(); sheet.getSheet().removeValueRecord(getRowNum(), cval); } if (cell.getColumnIndex()+1 == row.getLastCol()) { row.setLastCol(calculateNewLastCellPlusOne(row.getLastCol())); } if (cell.getColumnIndex() == row.getFirstCol()) { row.setFirstCol(calculateNewFirstCell(row.getFirstCol())); } }
private void removeCell(HSSFCell cell, boolean alsoRemoveRecords) { int column=cell.getColumnIndex(); if(column < 0) { throw new RuntimeException("Negative cell indexes not allowed"); } if(column >= cells.length || cell != cells[column]) { throw new RuntimeException("Specified cell is not from this row"); } if(cell.isPartOfArrayFormulaGroup()){ cell.notifyArrayFormulaChanging(); } cells[column]=null; if(alsoRemoveRecords) { CellValueRecordInterface cval = cell.getCellValueRecord(); sheet.getSheet().removeValueRecord(getRowNum(), cval); } if (cell.getColumnIndex()+1 == row.getLastCol()) { row.setLastCol(calculateNewLastCellPlusOne(row.getLastCol())); } if (cell.getColumnIndex() == row.getFirstCol()) { row.setFirstCol(calculateNewFirstCell(row.getFirstCol())); } }
private void removeCell(HSSFCell cell, boolean alsoRemoveRecords) { int column=cell.getColumnIndex(); if(column < 0) { throw new RuntimeException("Negative cell indexes not allowed"); } if(column >= cells.length || cell != cells[column]) { throw new RuntimeException("Specified cell is not from this row"); } if(cell.isPartOfArrayFormulaGroup()){ cell.notifyArrayFormulaChanging(); } cells[column]=null; if(alsoRemoveRecords) { CellValueRecordInterface cval = cell.getCellValueRecord(); sheet.getSheet().removeValueRecord(getRowNum(), cval); } if (cell.getColumnIndex()+1 == row.getLastCol()) { row.setLastCol(calculateNewLastCellPlusOne(row.getLastCol())); } if (cell.getColumnIndex() == row.getFirstCol()) { row.setFirstCol(calculateNewFirstCell(row.getFirstCol())); } }
private void validateArrayFormulas(CellRangeAddress region){ int firstRow = region.getFirstRow(); int firstColumn = region.getFirstColumn(); int lastRow = region.getLastRow(); int lastColumn = region.getLastColumn(); for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) { for (int colIn = firstColumn; colIn <= lastColumn; colIn++) { HSSFRow row = getRow(rowIn); if (row == null) continue; HSSFCell cell = row.getCell(colIn); if(cell == null) continue; if(cell.isPartOfArrayFormulaGroup()){ CellRangeAddress arrayRange = cell.getArrayFormulaRange(); if (arrayRange.getNumberOfCells() > 1 && ( arrayRange.isInRange(region.getFirstRow(), region.getFirstColumn()) || arrayRange.isInRange(region.getFirstRow(), region.getFirstColumn())) ){ String msg = "The range " + region.formatAsString() + " intersects with a multi-cell array formula. " + "You cannot merge cells of an array."; throw new IllegalStateException(msg); } } } } }
private void validateArrayFormulas(CellRangeAddress region) { int firstRow = region.getFirstRow(); int firstColumn = region.getFirstColumn(); int lastRow = region.getLastRow(); int lastColumn = region.getLastColumn(); for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) { for (int colIn = firstColumn; colIn <= lastColumn; colIn++) { HSSFRow row = getRow(rowIn); if (row == null) continue; HSSFCell cell = row.getCell(colIn); if (cell == null) continue; if (cell.isPartOfArrayFormulaGroup()) { CellRangeAddress arrayRange = cell.getArrayFormulaRange(); if (arrayRange.getNumberOfCells() > 1 && (arrayRange.isInRange(region.getFirstRow(), region.getFirstColumn()) || arrayRange.isInRange(region.getFirstRow(), region.getFirstColumn()))) { String msg = "The range " + region.formatAsString() + " intersects with a multi-cell array formula. " + "You cannot merge cells of an array."; throw new IllegalStateException(msg); } } } } }