/** * Template method for creating the POI {@link Workbook} instance. * <p>The default implementation creates a traditional {@link HSSFWorkbook}. * Spring-provided subclasses are overriding this for the OOXML-based variants; * custom subclasses may override this for reading a workbook from a file. * @param model the model Map * @param request current HTTP request (for taking the URL or headers into account) * @return the new {@link Workbook} instance */ protected Workbook createWorkbook(Map<String, Object> model, HttpServletRequest request) { return new HSSFWorkbook(); }
@Override public EvaluationCell getCell(int rowIndex, int columnIndex) { HSSFRow row = _hs.getRow(rowIndex); if (row == null) { return null; } HSSFCell cell = row.getCell(columnIndex); if (cell == null) { return null; } return new HSSFEvaluationCell(cell, this); }
/** * get the color value for the font */ public HSSFColor getHSSFColor(HSSFWorkbook wb) { HSSFPalette pallette = wb.getCustomPalette(); return pallette.getColor( getColor() ); }
HSSFWorkbook hwb = new HSSFWorkbook(); HSSFPalette palette = hwb.getCustomPalette(); // get the color which most closely matches the color you want to use HSSFColor myColor = palette.findSimilarColor(255, 0, 0); // get the palette index of that color short palIndex = myColor.getIndex(); // code to get the style for the cell goes here style.setFillForegroundColor(palIndex);
/** * set a string value for the cell. * * @param value value to set the cell to. For formulas we'll set the formula * cached string result, for String cells we'll set its value. For other types we will * change the cell to a string cell and set its value. * If value is null then we will change the cell to a Blank cell. */ public void setCellValue(String value) { HSSFRichTextString str = value == null ? null : new HSSFRichTextString(value); setCellValue(str); }
private float getRowHeightInPoints(HSSFSheet sheet, int rowNum) { HSSFRow row = sheet.getRow(rowNum); if (row == null) { return sheet.getDefaultRowHeightInPoints(); } return row.getHeightInPoints(); }
@Override public EvaluationSheet getSheet(int sheetIndex) { // TODO Cache these evaluation sheets so they aren't re-generated on every getSheet call return new HSSFEvaluationSheet(_uBook.getSheetAt(sheetIndex)); } @Override
/** * Returns the HSSFRow this cell belongs to * * @return the HSSFRow that owns this cell */ public HSSFRow getRow() { int rowIndex = getRowIndex(); return _sheet.getRow(rowIndex); }
public HSSFColor getFontColor() { return workbook.getCustomPalette().getColor( getFontColorIndex() ); }
/** * Returns the name of this sheet * * @return the name of this sheet */ @SuppressWarnings("resource") @Override public String getSheetName() { HSSFWorkbook wb = getWorkbook(); int idx = wb.getSheetIndex(this); return wb.getSheetName(idx); }
/** * Get the contents of the format string, by looking up * the DataFormat against the supplied low level workbook * @see org.apache.poi.hssf.usermodel.HSSFDataFormat */ public String getDataFormatString(org.apache.poi.hssf.model.InternalWorkbook workbook) { HSSFDataFormat format = new HSSFDataFormat( workbook ); return format.getFormat(getDataFormat()); }
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); } } }
/** gets the named range name * @param index the named range index (0 based) * @return named range name */ public String getNameName(int index){ return getNameAt(index).getNameName(); }
@Override public int getSheetIndex(EvaluationSheet evalSheet) { HSSFSheet sheet = ((HSSFEvaluationSheet)evalSheet).getHSSFSheet(); return _uBook.getSheetIndex(sheet); } @Override
/** * YK: used to create autofilters * * @see org.apache.poi.hssf.usermodel.HSSFSheet#setAutoFilter(org.apache.poi.ss.util.CellRangeAddress) */ HSSFSimpleShape createComboBox(HSSFAnchor anchor) { HSSFCombobox shape = new HSSFCombobox(null, anchor); addShape(shape); onCreate(shape); return shape; }
/** * gets the font for this style * @param parentWorkbook The HSSFWorkbook that this style belongs to * @see org.apache.poi.hssf.usermodel.HSSFCellStyle#getFontIndexAsInt() * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(int) */ public HSSFFont getFont(org.apache.poi.ss.usermodel.Workbook parentWorkbook) { return ((HSSFWorkbook) parentWorkbook).getFontAt(getFontIndexAsInt()); }
public void drawOval(int x, int y, int width, int height) { getEscherGraphics().drawOval(x,y,width,height); // draw(new java.awt.geom.Ellipse2D.Float(x, y, width, height)); }
/** * Used internally to create a high level Row object from a low level row object. * USed when reading an existing file * * @param row low level record to represent as a high level Row and add to sheet * @return HSSFRow high level representation */ private HSSFRow createRowFromRecord(RowRecord row) { HSSFRow hrow = new HSSFRow(_workbook, this, row); addRow(hrow, false); return hrow; }
/** * @return the sheet which contains the picture shape */ @Override public HSSFSheet getSheet() { return getPatriarch().getSheet(); } }
/** * Template method for creating the POI {@link Workbook} instance. * <p>The default implementation creates a traditional {@link HSSFWorkbook}. * Spring-provided subclasses are overriding this for the OOXML-based variants; * custom subclasses may override this for reading a workbook from a file. * @param model the model Map * @param request current HTTP request (for taking the URL or headers into account) * @return the new {@link Workbook} instance */ protected Workbook createWorkbook(Map<String, Object> model, HttpServletRequest request) { return new HSSFWorkbook(); }