/** * Fired when a formula is deleted from this workbook, * for example when calling cell.setCellFormula(null) * * @see XSSFCell#setCellFormula(String) */ protected void onDeleteFormula(XSSFCell cell){ if(calcChain != null) { int sheetId = (int)cell.getSheet().sheet.getSheetId(); calcChain.removeItem(sheetId, cell.getReference()); } }
/** * Returns the sheet's comments object if there is one, * or null if not * * @param create create a new comments table if it does not exist */ protected CommentsTable getCommentsTable(boolean create) { if(sheetComments == null && create){ // Try to create a comments table with the same number as // the sheet has (i.e. sheet 1 -> comments 1) try { sheetComments = (CommentsTable)createRelationship( XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), (int)sheet.getSheetId()); } catch(PartAlreadyExistsException e) { // Technically a sheet doesn't need the same number as // it's comments, and clearly someone has already pinched // our number! Go for the next available one instead sheetComments = (CommentsTable)createRelationship( XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), -1); } } return sheetComments; }
while(true) { for(XSSFSheet sh : sheets) { sheetNumber = (int)Math.max(sh.sheet.getSheetId() + 1, sheetNumber);
public void updateCellReferencesForShifting(String msg){ if(isPartOfArrayFormulaGroup()) notifyArrayFormulaChanging(msg); CalculationChain calcChain = getSheet().getWorkbook().getCalculationChain(); int sheetId = (int)getSheet().sheet.getSheetId(); //remove the reference in the calculation chain if(calcChain != null) calcChain.removeItem(sheetId, getReference()); CTCell ctCell = getCTCell(); String r = new CellReference(getRowIndex(), getColumnIndex()).formatAsString(); ctCell.setR(r); }
/** * Fired when a formula is deleted from this workbook, * for example when calling cell.setCellFormula(null) * * @see XSSFCell#setCellFormula(String) */ protected void onDeleteFormula(XSSFCell cell){ if(calcChain != null) { int sheetId = (int)cell.getSheet().sheet.getSheetId(); calcChain.removeItem(sheetId, cell.getReference()); } }
/** * Fired when a formula is deleted from this workbook, * for example when calling cell.setCellFormula(null) * * @see XSSFCell#setCellFormula(String) */ protected void onDeleteFormula(XSSFCell cell){ if(calcChain != null) { int sheetId = (int)cell.getSheet().sheet.getSheetId(); calcChain.removeItem(sheetId, cell.getReference()); } }
/** * Returns the sheet's comments object if there is one, * or null if not * * @param create create a new comments table if it does not exist */ protected CommentsTable getCommentsTable(boolean create) { if(sheetComments == null && create){ // Try to create a comments table with the same number as // the sheet has (i.e. sheet 1 -> comments 1) try { sheetComments = (CommentsTable)createRelationship( XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), (int)sheet.getSheetId()); } catch(PartAlreadyExistsException e) { // Technically a sheet doesn't need the same number as // it's comments, and clearly someone has already pinched // our number! Go for the next available one instead sheetComments = (CommentsTable)createRelationship( XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), -1); } } return sheetComments; }
/** * Returns the sheet's comments object if there is one, * or null if not * * @param create create a new comments table if it does not exist */ protected CommentsTable getCommentsTable(boolean create) { if(sheetComments == null && create){ // Try to create a comments table with the same number as // the sheet has (i.e. sheet 1 -> comments 1) try { sheetComments = (CommentsTable)createRelationship( XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), (int)sheet.getSheetId()); } catch(PartAlreadyExistsException e) { // Technically a sheet doesn't need the same number as // it's comments, and clearly someone has already pinched // our number! Go for the next available one instead sheetComments = (CommentsTable)createRelationship( XSSFRelation.SHEET_COMMENTS, XSSFFactory.getInstance(), -1); } } return sheetComments; }
for(XSSFSheet sh : sheets) sheetNumber = (int)Math.max(sh.sheet.getSheetId() + 1, sheetNumber);
while(true) { for(XSSFSheet sh : sheets) { sheetNumber = (int)Math.max(sh.sheet.getSheetId() + 1, sheetNumber);
public void updateCellReferencesForShifting(String msg){ if(isPartOfArrayFormulaGroup()) notifyArrayFormulaChanging(msg); CalculationChain calcChain = getSheet().getWorkbook().getCalculationChain(); int sheetId = (int)getSheet().sheet.getSheetId(); //remove the reference in the calculation chain if(calcChain != null) calcChain.removeItem(sheetId, getReference()); CTCell ctCell = getCTCell(); String r = new CellReference(getRowIndex(), getColumnIndex()).formatAsString(); ctCell.setR(r); }
/** * update cell references when shifting rows * * @param n the number of rows to move */ protected void shift(int n) { int rownum = getRowNum() + n; CalculationChain calcChain = _sheet.getWorkbook().getCalculationChain(); int sheetId = (int)_sheet.sheet.getSheetId(); String msg = "Row[rownum="+getRowNum()+"] contains cell(s) included in a multi-cell array formula. " + "You cannot change part of an array."; for(Cell c : this){ XSSFCell cell = (XSSFCell)c; if(cell.isPartOfArrayFormulaGroup()){ cell.notifyArrayFormulaChanging(msg); } //remove the reference in the calculation chain if(calcChain != null) calcChain.removeItem(sheetId, cell.getReference()); CTCell ctCell = cell.getCTCell(); String r = new CellReference(rownum, cell.getColumnIndex()).formatAsString(); ctCell.setR(r); } setRowNum(rownum); } }