List of usage examples for org.apache.poi.ss.usermodel CellStyle getLocked
boolean getLocked();
From source file:com.canoo.webtest.plugins.exceltest.ExcelVerifyCellStyle.java
License:Open Source License
public void doExecute() throws Exception { final String[] border = separateSides(getBorder()); final String[] borderColor = separateSides(getBorderColor()); for (int i = 0; i < SIDES.length; i++) { checkFormat(SIDES[i] + "Border", border[i], getCellBorder(i)); checkFormat(SIDES[i] + "BorderColor", ExcelColorUtils.lookupStandardColorName(borderColor[i]), getCellBorderColor(i));//www. j a v a 2 s . c om } final Cell excelCell = getExcelCell(); checkFormat("type", getType(), ExcelCellUtils.getCellType(excelCell == null ? Cell.CELL_TYPE_BLANK : excelCell.getCellType())); if (excelCell == null) { if (cellNotRequired()) { return; } else { throw new StepExecutionException("Can't find cell for " + getCellReferenceStr(), this); } } final CellStyle cellStyle = excelCell.getCellStyle(); checkFormat("format", getFormat(), getExcelWorkbook().createDataFormat().getFormat(cellStyle.getDataFormat())); checkFormat("align", getAlign(), ExcelCellUtils.getAlignmentString(cellStyle.getAlignment())); checkFormat("valign", getValign(), ExcelCellUtils.getVerticalAlignmentString(cellStyle.getVerticalAlignment())); checkFormat("wrap", getWrap(), String.valueOf(cellStyle.getWrapText())); checkFormat("locked", getLocked(), String.valueOf(cellStyle.getLocked())); checkFormat("fontName", getFontName(), getFont(cellStyle).getFontName()); checkFormat("fontSize", getFontSize(), String.valueOf(getFont(cellStyle).getFontHeightInPoints())); checkFormat("fontStyle", sortElements(getFontStyle()), getFontStyle(getFont(cellStyle))); checkFormat("fillColor", ExcelColorUtils.lookupStandardColorName(getFillColor()), ExcelColorUtils.getColorName(this, cellStyle.getFillForegroundColorColor())); checkFormat("fillBackgroundColor", ExcelColorUtils.lookupStandardColorName(getFillBackgroundColor()), ExcelColorUtils.getColorName(this, cellStyle.getFillBackgroundColorColor())); checkFormat("textColor", ExcelColorUtils.lookupStandardColorName(getTextColor()), ExcelColorUtils.getColorName(this, getFont(cellStyle).getColor())); checkFormat("fillPattern", getFillPattern(), ExcelCellUtils.getFillPattern(cellStyle.getFillPattern())); }
From source file:com.ncc.excel.test.ExcelUtil.java
License:Apache License
/** * ????? /* www . j a v a 2 s .c o m*/ * * @param fromStyle * @param toStyle */ public static void copyCellStyle(CellStyle fromStyle, CellStyle toStyle) { toStyle.setAlignment(fromStyle.getAlignment()); // toStyle.setBorderBottom(fromStyle.getBorderBottom()); toStyle.setBorderLeft(fromStyle.getBorderLeft()); toStyle.setBorderRight(fromStyle.getBorderRight()); toStyle.setBorderTop(fromStyle.getBorderTop()); toStyle.setTopBorderColor(fromStyle.getTopBorderColor()); toStyle.setBottomBorderColor(fromStyle.getBottomBorderColor()); toStyle.setRightBorderColor(fromStyle.getRightBorderColor()); toStyle.setLeftBorderColor(fromStyle.getLeftBorderColor()); // ? toStyle.setFillBackgroundColor(fromStyle.getFillBackgroundColor()); toStyle.setFillForegroundColor(fromStyle.getFillForegroundColor()); // ?? toStyle.setDataFormat(fromStyle.getDataFormat()); toStyle.setFillPattern(fromStyle.getFillPattern()); // toStyle.setFont(fromStyle.getFont(null)); toStyle.setHidden(fromStyle.getHidden()); toStyle.setIndention(fromStyle.getIndention());// toStyle.setLocked(fromStyle.getLocked()); toStyle.setRotation(fromStyle.getRotation());// toStyle.setVerticalAlignment(fromStyle.getVerticalAlignment()); toStyle.setWrapText(fromStyle.getWrapText()); }
From source file:org.tiefaces.components.websheet.utility.CellStyleUtility.java
License:MIT License
/** * Setup cell style./*from www. j av a 2 s. c om*/ * * @param wb * the wb * @param fcell * the fcell * @param poiCell * the poi cell * @param rowHeight * the row height */ public static void setupCellStyle(final Workbook wb, final FacesCell fcell, final Cell poiCell, final float rowHeight) { CellStyle cellStyle = poiCell.getCellStyle(); if ((cellStyle != null) && (!cellStyle.getLocked())) { // not locked if (fcell.getInputType().isEmpty()) { fcell.setInputType(CellStyleUtility.getInputTypeFromCellType(poiCell)); } if (fcell.getControl().isEmpty() && (!fcell.getInputType().isEmpty())) { fcell.setControl("text"); } setInputStyleBaseOnInputType(fcell, poiCell); } String webStyle = getCellStyle(wb, poiCell, fcell.getInputType()) + getCellFontStyle(wb, poiCell) + getRowStyle(wb, poiCell, fcell.getInputType(), rowHeight, fcell.getRowspan()); fcell.setStyle(webStyle); fcell.setColumnStyle(getColumnStyle(wb, fcell, poiCell, rowHeight)); }
From source file:ru.icc.cells.ssdc.DataLoader.java
License:Apache License
private void fillCellStyle(CStyle cellStyle, CellStyle excelCellStyle) { Font excelFont = workbook.getFontAt(excelCellStyle.getFontIndex()); // TODO CFont newFont(excelFont) //CFont font = new CFont(); //cellStyle.setFont( font ); CFont font = cellStyle.getFont();/*from www . ja v a 2 s . co m*/ fillFont(font, excelFont); cellStyle.setHidden(excelCellStyle.getHidden()); cellStyle.setLocked(excelCellStyle.getLocked()); cellStyle.setWrapped(excelCellStyle.getWrapText()); cellStyle.setIndention(excelCellStyle.getIndention()); cellStyle.setRotation(excelCellStyle.getRotation()); cellStyle.setHorzAlignment(this.getHorzAlignment(excelCellStyle.getAlignment())); cellStyle.setVertAlignment(this.getVertAlignment(excelCellStyle.getVerticalAlignment())); CBorder leftBorder = cellStyle.getLeftBorder(); CBorder rightBorder = cellStyle.getRightBorder(); CBorder topBorder = cellStyle.getTopBorder(); CBorder bottomBorder = cellStyle.getBottomBorder(); BorderType lbType = this.convertBorderType(excelCellStyle.getBorderLeft()); BorderType rbType = this.convertBorderType(excelCellStyle.getBorderRight()); BorderType tbType = this.convertBorderType(excelCellStyle.getBorderTop()); BorderType bbType = this.convertBorderType(excelCellStyle.getBorderBottom()); leftBorder.setType(lbType); rightBorder.setType(rbType); topBorder.setType(tbType); bottomBorder.setType(bbType); // "Fill Background Color" ???, ??, // ? ??? . ? . // "Fill Foreground Color" XSSFColor bgColor = (XSSFColor) excelCellStyle.getFillBackgroundColorColor(); // ? Index 64, ? , , // ? ? null ? if (null != bgColor && 64 != bgColor.getIndexed()) { String bgColorHexRGB = bgColor.getARGBHex().substring(2); cellStyle.setBgColor(new CColor(bgColorHexRGB)); } // "Fill Background Color" ??, // ? ??? . XSSFColor fgColor = (XSSFColor) excelCellStyle.getFillForegroundColorColor(); if (null != fgColor && 64 != fgColor.getIndexed()) { String fgColorHexRGB = fgColor.getARGBHex().substring(2); cellStyle.setFgColor(new CColor(fgColorHexRGB)); } // TODO }