/** * The purpose of this method is to validate the cell state prior to modification * * @see #notifyArrayFormulaChanging() */ void notifyArrayFormulaChanging(String msg){ CellRangeAddress cra = getArrayFormulaRange(); if(cra.getNumberOfCells() > 1) { throw new IllegalStateException(msg); } //un-register the single-cell array formula from the parent XSSFSheet getRow().getSheet().removeArrayFormula(this); }
/** * @param startCell: first cell of merging area * @param endCell: last cell of merging area */ public static void mergeAndAlignCenter(HSSFCell startCell, HSSFCell endCell){ //finding reference of start and end cell; will result like $A$1 CellReference startCellRef= new CellReference(startCell.getRowIndex(),startCell.getColumnIndex()); CellReference endCellRef = new CellReference(endCell.getRowIndex(),endCell.getColumnIndex()); // forming string of references; will result like $A$1:$B$5 String cellRefernce = startCellRef.formatAsString()+":"+endCellRef.formatAsString(); //removing $ to make cellRefernce like A1:B5 cellRefernce = cellRefernce.replace("$",""); //passing cellRefernce to make a region CellRangeAddress region = CellRangeAddress.valueOf(cellRefernce); //use region to merge; though other method like sheet.addMergedRegion(new CellRangeAddress(1,1,4,1)); // is also available, but facing some problem right now. startCell.getRow().getSheet().addMergedRegion( region ); //setting alignment to center CellUtil.setAlignment(startCell, wb, CellStyle.ALIGN_CENTER); }
private void fixNeighbourCellBorders(HSSFCellStyle cellStyle, HSSFCell resultCell) { HSSFSheet sheet = resultCell.getRow().getSheet(); // disable neighboring cells border int columnIndex = resultCell.getColumnIndex(); int rowIndex = resultCell.getRowIndex(); // fix left border fixLeftBorder(cellStyle, sheet, columnIndex, resultCell); // fix right border fixRightBorder(cellStyle, sheet, columnIndex, resultCell); // fix up border fixUpBorder(cellStyle, sheet, columnIndex, rowIndex, resultCell); // fix down border fixDownBorder(cellStyle, sheet, columnIndex, rowIndex, resultCell); }
/** * The purpose of this method is to validate the cell state prior to modification * * @see #notifyArrayFormulaChanging() */ void notifyArrayFormulaChanging(String msg){ CellRangeAddress cra = getArrayFormulaRange(); if(cra.getNumberOfCells() > 1) { throw new IllegalStateException(msg); } //un-register the single-cell array formula from the parent XSSFSheet getRow().getSheet().removeArrayFormula(this); }
private void fixNeighbourCellBorders(HSSFCellStyle cellStyle, HSSFCell resultCell) { HSSFSheet sheet = resultCell.getRow().getSheet(); // disable neighboring cells border int columnIndex = resultCell.getColumnIndex(); int rowIndex = resultCell.getRowIndex(); // fix left border fixLeftBorder(cellStyle, sheet, columnIndex, resultCell); // fix right border fixRightBorder(cellStyle, sheet, columnIndex, resultCell); // fix up border fixUpBorder(cellStyle, sheet, columnIndex, rowIndex, resultCell); // fix down border fixDownBorder(cellStyle, sheet, columnIndex, rowIndex, resultCell); }
/** * The purpose of this method is to validate the cell state prior to modification * * @see #notifyArrayFormulaChanging() */ void notifyArrayFormulaChanging(String msg){ CellRangeAddress cra = getArrayFormulaRange(); if(cra.getNumberOfCells() > 1) { throw new IllegalStateException(msg); } //un-register the single-cell array formula from the parent XSSFSheet getRow().getSheet().removeArrayFormula(this); }
private void drawLabel(HSSFSheet sheet, HSSFCell cell) { final int defaultColumnWidth = 2048; // column width before resizing final int defaultRowHeight = 255; // row height before resizing final double xDistortionFactor = 1.0 * defaultColumnWidth / sheet.getColumnWidth(cell.getColumnIndex()); final double yDistortionFactor = 1.0 * defaultRowHeight / cell.getRow().getHeight(); final int dx1 = (int) (60 * xDistortionFactor); final int dy1 = (int) (60 * yDistortionFactor); final int dx2 = (int) (200 * xDistortionFactor); final int dy2 = (int) (200 * yDistortionFactor); final short columnIndex = (short) cell.getColumnIndex(); final int rowIndex = cell.getRowIndex(); final HSSFClientAnchor anchor = new HSSFClientAnchor(dx1, dy1, dx2, dy2, columnIndex, rowIndex, columnIndex, rowIndex); anchor.setAnchorType(ClientAnchor.MOVE_DONT_RESIZE); HSSFSimpleShape shape = sheet.getDrawingPatriarch().createSimpleShape(anchor); shape.setShapeType(HSSFSimpleShape.OBJECT_TYPE_OVAL); ... }
/** * The purpose of this method is to validate the cell state prior to modification * * @see #notifyArrayFormulaChanging() */ void notifyArrayFormulaChanging(String msg){ CellRangeAddress cra = getArrayFormulaRange(); if(cra.getNumberOfCells() > 1) { throw new IllegalStateException(msg); } //un-register the single-cell array formula from the parent XSSFSheet getRow().getSheet().removeArrayFormula(this); }
resultRow.setHeight(templateCell.getRow().getHeight());
private boolean checkDescriptionLength(final HSSFCell commentCell) { boolean checkSmall; HSSFRow row = commentCell.getRow(); int orderDescriptionLength = commentCell.getStringCellValue().length(); if (orderDescriptionLength <= 34) { row.setHeightInPoints(20); checkSmall = false; } else if ((orderDescriptionLength >= 34) && (orderDescriptionLength <= 69)) { row.setHeightInPoints(30); checkSmall = false; } else { row.setHeightInPoints(42); checkSmall = true; } return checkSmall; }
resultRow.setHeight(templateCell.getRow().getHeight());
if ( cellStyleIndex != 0 ) HSSFWorkbook workbook = cell.getRow().getSheet().getWorkbook(); String mainCssClass = getStyleClassName( workbook, cellStyle ); if ( wrapInDivs )
HSSFWorkbook workbook = cell.getRow().getSheet().getWorkbook(); String mainCssClass = getStyleClassName( workbook, cellStyle );