/** * Returns the cell at the given (0 based) index, * with the {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy} from the parent Workbook. * * @return the cell at the given (0 based) index */ @Override public XSSFCell getCell(int cellnum) { return getCell(cellnum, _sheet.getWorkbook().getMissingCellPolicy()); }
/** * Returns all the pivot tables for this Sheet */ @Beta public List<XSSFPivotTable> getPivotTables() { List<XSSFPivotTable> tables = new ArrayList<>(); for (XSSFPivotTable table : getWorkbook().getPivotTables()) { if (table.getParent() == this) { tables.add(table); } } return tables; }
/** * Returns the CellStyle that applies to the given * (0 based) column, or null if no style has been * set for that column */ @Override public CellStyle getColumnStyle(int column) { int idx = columnHelper.getColDefaultStyle(column); return getWorkbook().getCellStyleAt((short)(idx == -1 ? 0 : idx)); }
/** * Create a pivot table using the Name range, at the given position. * If the source reference contains a sheet name, that sheet is used, otherwise this sheet is assumed as the source sheet. * @param source location of pivot data * @param position A reference to the top left cell where the pivot table will start * @return The pivot table */ @Beta public XSSFPivotTable createPivotTable(Name source, CellReference position) { return createPivotTable(source, position, getWorkbook().getSheet(source.getSheetName())); }
protected AbstractCellRangeDataSource(XSSFSheet sheet, CellRangeAddress cellRangeAddress) { this.sheet = sheet; // Make copy since CellRangeAddress is mutable. this.cellRangeAddress = cellRangeAddress.copy(); this.numOfCells = this.cellRangeAddress.getNumberOfCells(); this.evaluator = sheet.getWorkbook().getCreationHelper().createFormulaEvaluator(); }
public XSSFColorScaleFormatting getColorScaleFormatting() { if (_cfRule.isSetColorScale()) { CTColorScale scale = _cfRule.getColorScale(); return new XSSFColorScaleFormatting(scale, _sh.getWorkbook().getStylesSource().getIndexedColors()); } else { return null; } }
/** * @since 3.17 beta 1 */ public TableStyleInfo getStyle() { if (! ctTable.isSetTableStyleInfo()) return null; return new XSSFTableStyleInfo(((XSSFSheet) getParent()).getWorkbook().getStylesSource(), ctTable.getTableStyleInfo()); }
public XSSFDataBarFormatting getDataBarFormatting() { if (_cfRule.isSetDataBar()) { CTDataBar bar = _cfRule.getDataBar(); return new XSSFDataBarFormatting(bar, _sh.getWorkbook().getStylesSource().getIndexedColors()); } else { return null; } }
/** * Create a pivot table using the Table, at the given position. * Tables are required to have a sheet reference, so no additional logic around reference sheet is needed. * @param source location of pivot data * @param position A reference to the top left cell where the pivot table will start * @return The pivot table */ @Beta public XSSFPivotTable createPivotTable(final Table source, CellReference position) { return createPivotTable(position, getWorkbook().getSheet(source.getSheetName()), wsSource -> wsSource.setName(source.getName())); }
/** * Get the area that this table covers. * * @return the table's area or {@code null} if the area has not been * initialized * @since 4.0.0 */ public AreaReference getArea() { String ref = ctTable.getRef(); if (ref != null) { SpreadsheetVersion version = getXSSFSheet().getWorkbook().getSpreadsheetVersion(); return new AreaReference(ctTable.getRef(), version); } else { return null; } }
/** * Create a pivot table using the AreaReference range, at the given position. * If the source reference contains a sheet name, that sheet is used, otherwise this sheet is assumed as the source sheet. * @param source location of pivot data * @param position A reference to the top left cell where the pivot table will start * @return The pivot table */ @Beta public XSSFPivotTable createPivotTable(AreaReference source, CellReference position){ final String sourceSheetName = source.getFirstCell().getSheetName(); if(sourceSheetName != null && !sourceSheetName.equalsIgnoreCase(this.getSheetName())) { final XSSFSheet sourceSheet = getWorkbook().getSheet(sourceSheetName); return createPivotTable(source, position, sourceSheet); } return createPivotTable(source, position, this); }
/** * @return - font formatting object if defined, <code>null</code> otherwise */ public XSSFFontFormatting getFontFormatting(){ CTDxf dxf = getDxf(false); if(dxf == null || !dxf.isSetFont()) return null; return new XSSFFontFormatting(dxf.getFont(), _sh.getWorkbook().getStylesSource().getIndexedColors()); }
/** * @return - border formatting object if defined, <code>null</code> otherwise */ public XSSFBorderFormatting getBorderFormatting(){ CTDxf dxf = getDxf(false); if(dxf == null || !dxf.isSetBorder()) return null; return new XSSFBorderFormatting(dxf.getBorder(), _sh.getWorkbook().getStylesSource().getIndexedColors()); }
/** * @return - pattern formatting object if defined, <code>null</code> otherwise */ public XSSFPatternFormatting getPatternFormatting(){ CTDxf dxf = getDxf(false); if(dxf == null || !dxf.isSetFill()) return null; return new XSSFPatternFormatting(dxf.getFill(), _sh.getWorkbook().getStylesSource().getIndexedColors()); }
/** * Returns the whole-row cell style. Most rows won't * have one of these, so will return null. Call * {@link #isFormatted()} to check first. */ @Override public XSSFCellStyle getRowStyle() { if(!isFormatted()) { return null; } StylesTable stylesSource = getSheet().getWorkbook().getStylesSource(); if(stylesSource.getNumCellStyles() > 0) { return stylesSource.getStyleAt((int)_row.getS()); } else { return null; } }
/** * Get background color of the sheet tab. * Returns <tt>null</tt> if no sheet tab color is set. * * @return the background color of the sheet tab */ public XSSFColor getTabColor() { CTSheetPr pr = worksheet.getSheetPr(); if(pr == null) { pr = worksheet.addNewSheetPr(); } if (!pr.isSetTabColor()) { return null; } return XSSFColor.from(pr.getTabColor(), getWorkbook().getStylesSource().getIndexedColors()); }
/** * Create a new border formatting structure if it does not exist, * otherwise just return existing object. * * @return - border formatting object, never returns <code>null</code>. */ public XSSFBorderFormatting createBorderFormatting(){ CTDxf dxf = getDxf(true); CTBorder border; if(!dxf.isSetBorder()) { border = dxf.addNewBorder(); } else { border = dxf.getBorder(); } return new XSSFBorderFormatting(border, _sh.getWorkbook().getStylesSource().getIndexedColors()); }
/** * Create a new font formatting structure if it does not exist, * otherwise just return existing object. * * @return - font formatting object, never returns <code>null</code>. */ public XSSFFontFormatting createFontFormatting(){ CTDxf dxf = getDxf(true); CTFont font; if(!dxf.isSetFont()) { font = dxf.addNewFont(); } else { font = dxf.getFont(); } return new XSSFFontFormatting(font, _sh.getWorkbook().getStylesSource().getIndexedColors()); }
/*package*/ CTDxf getDxf(boolean create){ StylesTable styles = _sh.getWorkbook().getStylesSource(); CTDxf dxf = null; if(styles._getDXfsSize() > 0 && _cfRule.isSetDxfId()){ int dxfId = (int)_cfRule.getDxfId(); dxf = styles.getDxfAt(dxfId); } if(create && dxf == null) { dxf = CTDxf.Factory.newInstance(); int dxfId = styles.putDxf(dxf); _cfRule.setDxfId(dxfId - 1); } return dxf; }
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); }