Example usage for org.apache.poi.ss.usermodel CellStyle getIndention

List of usage examples for org.apache.poi.ss.usermodel CellStyle getIndention

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel CellStyle getIndention.

Prototype

short getIndention();

Source Link

Document

get the number of spaces to indent the text in the cell

Usage

From source file:com.ncc.excel.test.ExcelUtil.java

License:Apache License

/** 
 * ????? // w ww . 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:com.vaadin.addon.spreadsheet.SpreadsheetStyleFactory.java

License:Open Source License

private void addCellStyleCSS(CellStyle cellStyle) {

    if (cellStyle.getIndex() == 0) {
        // default cell style, do not change.
        return;/* w w  w  .j  ava  2  s.c om*/
    }

    StringBuilder sb = new StringBuilder();

    fontStyle(sb, cellStyle);
    colorConverter.colorStyles(cellStyle, sb);
    borderStyles(sb, cellStyle);
    if (cellStyle.getAlignment() != defaultTextAlign) {
        styleOut(sb, "text-align", cellStyle.getAlignment(), ALIGN);
        // TODO For correct overflow, rtl should be used for right align
        // if (cellStyle.getAlignment() == ALIGN_RIGHT) {
        // sb.append("direction:rtl;");
        // }
    }

    // excel default is bottom, so that is what we have in the CSS base
    // files.
    // TODO This only works on modern (10+) IE.
    styleOut(sb, "justify-content", cellStyle.getVerticalAlignment(), VERTICAL_ALIGN);

    if (cellStyle.getWrapText()) { // default is to overflow
        sb.append("overflow:hidden;white-space:normal;");
    }

    if (cellStyle.getIndention() > 0) {
        sb.append("padding-left: " + cellStyle.getIndention() + "em;");
    }

    spreadsheet.getState().cellStyleToCSSStyle.put((int) cellStyle.getIndex(), sb.toString());
}

From source file:org.drugepi.table.CellStyleLookup.java

License:Mozilla Public License

public static String styleToString(CellStyle style) {
    StringBuffer sb = new StringBuffer();
    sb.append("getDataFormatString=" + style.getDataFormatString() + "\n");
    sb.append("getFontIndex=" + style.getFontIndex() + "\n");
    sb.append("getHidden=" + style.getHidden() + "\n");
    sb.append("getAlignment=" + style.getAlignment() + "\n");
    sb.append("getWrapText=" + style.getWrapText() + "\n");
    sb.append("getVerticalAlignment=" + style.getVerticalAlignment() + "\n");
    sb.append("getRotation=" + style.getRotation() + "\n");
    sb.append("getIndention=" + style.getIndention() + "\n");
    sb.append("getBorderLeft=" + style.getBorderLeft() + "\n");
    sb.append("getBorderRight=" + style.getBorderRight() + "\n");
    sb.append("getBorderTop=" + style.getBorderTop() + "\n");
    sb.append("getBorderBottom=" + style.getBorderBottom() + "\n");
    sb.append("getLeftBorderColor=" + style.getLeftBorderColor() + "\n");
    sb.append("getRightBorderColor=" + style.getRightBorderColor() + "\n");
    sb.append("getTopBorderColor=" + style.getTopBorderColor() + "\n");
    sb.append("getBottomBorderColor=" + style.getBottomBorderColor() + "\n");
    sb.append("getFillPattern=" + style.getFillPattern() + "\n");
    sb.append("getFillBackgroundColor=" + style.getFillBackgroundColor() + "\n");
    sb.append("getFillForegroundColor=" + style.getFillForegroundColor() + "\n");

    return sb.toString();
}

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  w  ww. j ava  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   
}