/** Creates new HSSFCellStyle why would you want to do this?? */ protected HSSFCellStyle(short index, ExtendedFormatRecord rec, HSSFWorkbook workbook) { this(index, rec, workbook.getWorkbook()); } protected HSSFCellStyle(short index, ExtendedFormatRecord rec, InternalWorkbook workbook)
/** * Returns the Workbook that this Cell is bound to */ protected InternalWorkbook getBoundWorkbook() { return _book.getWorkbook(); }
private HSSFEvaluationWorkbook(HSSFWorkbook book) { _uBook = book; _iBook = book.getWorkbook(); }
/** * Verifies that this style belongs to the supplied Workbook. * Will throw an exception if it belongs to a different one. * This is normally called when trying to assign a style to a * cell, to ensure the cell and the style are from the same * workbook (if they're not, it won't work) * @throws IllegalArgumentException if there's a workbook mis-match */ public void verifyBelongsToWorkbook(HSSFWorkbook wb) { if(wb.getWorkbook() != _workbook) { throw new IllegalArgumentException("This Style does not belong to the supplied Workbook. Are you trying to assign a style from one workbook to the cell of a differnt workbook?"); } }
/** * Delete the printarea for the sheet specified * @param sheetIndex Zero-based sheet index (0 = First Sheet) */ @Override public void removePrintArea(int sheetIndex) { getWorkbook().removeBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1); }
/** * Creates new HSSFSheet - called by HSSFWorkbook to create a sheet from * scratch. You should not be calling this from application code (its protected anyhow). * * @param workbook - The HSSF Workbook object associated with the sheet. * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#createSheet() */ protected HSSFSheet(HSSFWorkbook workbook) { _sheet = InternalSheet.createSheet(); _rows = new TreeMap<>(); this._workbook = workbook; this._book = workbook.getWorkbook(); }
/** Get the sheets name which this named range is referenced to * @return sheet name, which this named range referred to */ public String getSheetName() { int indexToExternSheet = _definedNameRec.getExternSheetNumber(); return _book.getWorkbook().findSheetFirstNameFromExternSheet(indexToExternSheet); }
/** * Whether Excel will be asked to recalculate all formulas when the workbook is opened. * * @since 3.8 */ @Override public boolean getForceFormulaRecalculation(){ InternalWorkbook iwb = getWorkbook(); RecalcIdRecord recalc = (RecalcIdRecord)iwb.findFirstRecordBySid(RecalcIdRecord.sid); return recalc != null && recalc.getEngineId() != 0; }
/** * set a date value for the cell. Excel treats dates as numeric so you will need to format the cell as * a date. * * @param value the date value to set this cell to. For formulas we'll set the * precalculated value, for numerics we'll set its value. For other types we * will change the cell to a numeric cell and set its value. */ public void setCellValue(Date value) { setCellValue(HSSFDateUtil.getExcelDate(value, _book.getWorkbook().isUsing1904DateWindowing())); }
private static boolean isUserDefined(HSSFWorkbook workbook, int index) { StyleRecord styleRecord = workbook.getWorkbook().getStyleRecord(index); return styleRecord != null && !styleRecord.isBuiltin() && styleRecord.getName() != null; } }
/** * get the style for the cell. This is a reference to a cell style contained in the workbook * object. * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getCellStyleAt(int) */ public HSSFCellStyle getCellStyle() { short styleIndex=_record.getXFIndex(); ExtendedFormatRecord xf = _book.getWorkbook().getExFormatAt(styleIndex); return new HSSFCellStyle(styleIndex, xf, _book); }
/** * Get the contents of the format string, by looking up * the DataFormat against the supplied workbook * @see org.apache.poi.hssf.usermodel.HSSFDataFormat * * @return the format string or "General" if not found */ public String getDataFormatString(org.apache.poi.ss.usermodel.Workbook workbook) { HSSFDataFormat format = new HSSFDataFormat( ((HSSFWorkbook)workbook).getWorkbook() ); int idx = getDataFormat(); return idx == -1 ? "General" : format.getFormat(getDataFormat()); } /**
/** * Returns the whole-row cell styles. Most rows won't * have one of these, so will return null. Call * {@link #isFormatted()} to check first. */ @Override public HSSFCellStyle getRowStyle() { if(!isFormatted()) { return null; } short styleIndex = row.getXFIndex(); ExtendedFormatRecord xf = book.getWorkbook().getExFormatAt(styleIndex); return new HSSFCellStyle(styleIndex, xf, book); } /**
/** * @return new unique shapeId */ int newShapeId() { DrawingManager2 dm = _sheet.getWorkbook().getWorkbook().getDrawingManager(); EscherDgRecord dg = _boundAggregate.getEscherContainer().getChildById(EscherDgRecord.RECORD_ID); return dm.allocateShapeId(dg); }
/** * Return the dimension of the embedded image in pixel * * @return image dimension in pixels */ @Override public Dimension getImageDimension(){ InternalWorkbook iwb = getPatriarch().getSheet().getWorkbook().getWorkbook(); EscherBSERecord bse = iwb.getBSERecord(getPictureIndex()); byte[] data = bse.getBlipRecord().getPicturedata(); int type = bse.getBlipTypeWin32(); return ImageUtils.getImageDimension(new ByteArrayInputStream(data), type); }
void afterCreate() { DrawingManager2 drawingManager = _sheet.getWorkbook().getWorkbook().getDrawingManager(); short dgId = drawingManager.findNewDrawingGroupId(); _boundAggregate.setDgId(dgId); _boundAggregate.setMainSpRecordId(newShapeId()); drawingManager.incrementDrawingsSaved(); }
public void setBackgroundImage(int pictureIndex){ setPropertyValue(new EscherSimpleProperty( EscherProperties.FILL__PATTERNTEXTURE, false, true, pictureIndex)); setPropertyValue(new EscherSimpleProperty( EscherProperties.FILL__FILLTYPE, false, false, FILL_TYPE_PICTURE)); EscherBSERecord bse = getPatriarch().getSheet().getWorkbook().getWorkbook().getBSERecord(pictureIndex); bse.setRef(bse.getRef() + 1); }
@Override void afterInsert(HSSFPatriarch patriarch) { EscherAggregate agg = patriarch.getBoundAggregate(); agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord()); EscherBSERecord bse = patriarch.getSheet().getWorkbook().getWorkbook().getBSERecord(getPictureIndex()); bse.setRef(bse.getRef() + 1); }
@Override void afterInsert(HSSFPatriarch patriarch) { EscherAggregate agg = patriarch.getBoundAggregate(); agg.associateShapeToObjRecord(getEscherContainer().getChildById(EscherClientDataRecord.RECORD_ID), getObjRecord()); if(getPictureIndex() != -1) { EscherBSERecord bse = patriarch.getSheet().getWorkbook().getWorkbook().getBSERecord(getPictureIndex()); bse.setRef(bse.getRef() + 1); } }
public void resetBackgroundImage(){ EscherSimpleProperty property = getOptRecord().lookup(EscherProperties.FILL__PATTERNTEXTURE); if (null != property){ EscherBSERecord bse = getPatriarch().getSheet().getWorkbook().getWorkbook().getBSERecord(property.getPropertyValue()); bse.setRef(bse.getRef() - 1); getOptRecord().removeEscherProperty(EscherProperties.FILL__PATTERNTEXTURE); } setPropertyValue(new EscherSimpleProperty( EscherProperties.FILL__FILLTYPE, false, false, FILL_TYPE_SOLID)); }