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); } } }
/** * Called when this cell is modified. * <p> * The purpose of this method is to validate the cell state prior to modification. * </p> * * @see #setCellFormula(String) * @see HSSFRow#removeCell(org.apache.poi.ss.usermodel.Cell) * @see org.apache.poi.hssf.usermodel.HSSFSheet#removeRow(org.apache.poi.ss.usermodel.Row) * @see org.apache.poi.hssf.usermodel.HSSFSheet#shiftRows(int, int, int) * @see org.apache.poi.hssf.usermodel.HSSFSheet#addMergedRegion(org.apache.poi.ss.util.CellRangeAddress) * @throws IllegalStateException if modification is not allowed */ void notifyArrayFormulaChanging(){ CellReference ref = new CellReference(this); String msg = "Cell "+ref.formatAsString()+" is part of a multi-cell array formula. " + "You cannot change part of an array."; 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 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); } /**
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); } } }
/** * Called when this cell is modified. * <p> * The purpose of this method is to validate the cell state prior to modification. * </p> * * @see #setCellFormula(String) * @see HSSFRow#removeCell(org.apache.poi.ss.usermodel.Cell) * @see org.apache.poi.hssf.usermodel.HSSFSheet#removeRow(org.apache.poi.ss.usermodel.Row) * @see org.apache.poi.hssf.usermodel.HSSFSheet#shiftRows(int, int, int) * @see org.apache.poi.hssf.usermodel.HSSFSheet#addMergedRegion(org.apache.poi.ss.util.CellRangeAddress) * @throws IllegalStateException if modification is not allowed */ void notifyArrayFormulaChanging(){ CellReference ref = new CellReference(this); String msg = "Cell "+ref.formatAsString()+" is part of a multi-cell array formula. " + "You cannot change part of an array."; notifyArrayFormulaChanging(msg); }
/** * Called when this cell is modified. * <p> * The purpose of this method is to validate the cell state prior to modification. * </p> * * @see #setCellType(int) * @see #setCellFormula(String) * @see HSSFRow#removeCell(org.apache.poi.ss.usermodel.Cell) * @see org.apache.poi.hssf.usermodel.HSSFSheet#removeRow(org.apache.poi.ss.usermodel.Row) * @see org.apache.poi.hssf.usermodel.HSSFSheet#shiftRows(int, int, int) * @see org.apache.poi.hssf.usermodel.HSSFSheet#addMergedRegion(org.apache.poi.ss.util.CellRangeAddress) * @throws IllegalStateException if modification is not allowed */ void notifyArrayFormulaChanging(){ CellReference ref = new CellReference(this); String msg = "Cell "+ref.formatAsString()+" is part of a multi-cell array formula. " + "You cannot change part of an array."; notifyArrayFormulaChanging(msg); }
/** * Called when this cell is modified. * <p> * The purpose of this method is to validate the cell state prior to modification. * </p> * * @see #setCellType(int) * @see #setCellFormula(String) * @see HSSFRow#removeCell(org.apache.poi.ss.usermodel.Cell) * @see org.apache.poi.hssf.usermodel.HSSFSheet#removeRow(org.apache.poi.ss.usermodel.Row) * @see org.apache.poi.hssf.usermodel.HSSFSheet#shiftRows(int, int, int) * @see org.apache.poi.hssf.usermodel.HSSFSheet#addMergedRegion(org.apache.poi.ss.util.CellRangeAddress) * @throws IllegalStateException if modification is not allowed */ void notifyArrayFormulaChanging(){ CellReference ref = new CellReference(this); String msg = "Cell "+ref.formatAsString()+" is part of a multi-cell array formula. " + "You cannot change part of an array."; 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 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())); } }
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(CELL_TYPE_BLANK, false, row, col, styleIndex); return; } int sheetIndex = _book.getSheetIndex(_sheet); Ptg[] ptgs = HSSFFormulaParser.parse(formula, _book, FormulaType.CELL, sheetIndex); setCellType(CELL_TYPE_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); } /**
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); } /**