/** * Creates a new XSSFRichTextString for you. */ @Override public XSSFRichTextString createRichTextString(String text) { XSSFRichTextString rt = new XSSFRichTextString(text); rt.setStylesTableReference(workbook.getStylesSource()); return rt; }
@Override public XSSFColor createExtendedColor() { return XSSFColor.from(CTColor.Factory.newInstance(), workbook.getStylesSource().getIndexedColors()); }
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; } }
/** * @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()); }
/** * Create a new pattern formatting structure if it does not exist, * otherwise just return existing object. * * @return - pattern formatting object, never returns <code>null</code>. */ public XSSFPatternFormatting createPatternFormatting(){ CTDxf dxf = getDxf(true); CTFill fill; if(!dxf.isSetFill()) { fill = dxf.addNewFill(); } else { fill = dxf.getFill(); } return new XSSFPatternFormatting(fill, _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; }
/** * Applies a whole-row cell styling to the row. * If the value is null then the style information is removed, * causing the cell to used the default workbook style. */ @Override public void setRowStyle(CellStyle style) { if(style == null) { if(_row.isSetS()) { _row.unsetS(); _row.unsetCustomFormat(); } } else { StylesTable styleSource = getSheet().getWorkbook().getStylesSource(); XSSFCellStyle xStyle = (XSSFCellStyle)style; xStyle.verifyBelongsToStylesSource(styleSource); long idx = styleSource.putStyle(xStyle); _row.setS(idx); _row.setCustomFormat(true); } }
/** * Construct a XSSFCell. * * @param row the parent row. * @param cell the xml bean containing information about the cell. */ protected XSSFCell(XSSFRow row, CTCell cell) { _cell = cell; _row = row; if (cell.getR() != null) { _cellNum = new CellReference(cell.getR()).getCol(); } else { int prevNum = row.getLastCellNum(); if(prevNum != -1){ _cellNum = row.getCell(prevNum-1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getColumnIndex() + 1; } } _sharedStringSource = row.getSheet().getWorkbook().getSharedStringSource(); _stylesSource = row.getSheet().getWorkbook().getStylesSource(); }
return new XSSFDataBarFormatting(bar, _sh.getWorkbook().getStylesSource().getIndexedColors());
str.setStylesTableReference(wb.getStylesSource());
return new XSSFColorScaleFormatting(scale, _sh.getWorkbook().getStylesSource().getIndexedColors());
public XSSFColorScaleFormatting getColorScaleFormatting() { if (_cfRule.isSetColorScale()) { CTColorScale scale = _cfRule.getColorScale(); return new XSSFColorScaleFormatting(scale, _sh.getWorkbook().getStylesSource().getIndexedColors()); } else { return null; } }