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

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

Introduction

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

Prototype

void setWrapText(boolean wrapped);

Source Link

Document

Set whether the text should be wrapped.

Usage

From source file:com.ferid.app.classroom.utility.ExcelStyleManager.java

License:Apache License

/**
 * Header cell style (dates)/*from  ww  w .ja  va 2  s  .  c  om*/
 * @param wb Workbook
 * @return CellStyle
 */
public static CellStyle getHeaderCellStyle(Workbook wb) {
    CellStyle cellStyle = wb.createCellStyle();

    cellStyle.setAlignment(HorizontalAlignment.CENTER);

    Font font = wb.createFont();
    font.setFontHeightInPoints((short) 8);
    font.setBold(true);
    cellStyle.setFont(font);

    cellStyle.setWrapText(true);

    cellStyle.setFillForegroundColor(IndexedColors.LIGHT_TURQUOISE.getIndex());
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    cellStyle.setBorderLeft(BorderStyle.THIN);
    cellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());

    return cellStyle;
}

From source file:com.ferid.app.classroom.utility.ExcelStyleManager.java

License:Apache License

/**
 * Content cell style (presence)/*from   w w  w . j a  v a2s .  c o  m*/
 * @param wb Workbook
 * @return CellStyle
 */
public static CellStyle getContentCellStyle(Workbook wb) {
    CellStyle cellStyle = wb.createCellStyle();

    cellStyle.setAlignment(HorizontalAlignment.CENTER);

    Font font = wb.createFont();
    font.setFontHeightInPoints((short) 8);
    cellStyle.setFont(font);

    cellStyle.setWrapText(true);

    cellStyle.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    cellStyle.setBorderLeft(BorderStyle.THIN);
    cellStyle.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setTopBorderColor(IndexedColors.BLACK.getIndex());

    return cellStyle;
}

From source file:com.firstonesoft.poi.TimesheetDemo.java

License:Apache License

/**
 * Create a library of cell styles//from w w  w.  j  av a 2  s  .c  om
 */
private static Map<String, CellStyle> createStyles(Workbook wb) {
    Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

    CellStyle style;

    Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short) 18);
    titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setFont(titleFont);
    styles.put("title", style);

    Font monthFont = wb.createFont();
    monthFont.setFontHeightInPoints((short) 11);
    monthFont.setColor(IndexedColors.WHITE.getIndex());
    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setFont(monthFont);
    style.setWrapText(true);
    styles.put("header", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setWrapText(true);
    style.setBorderRight(CellStyle.BORDER_THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(CellStyle.BORDER_THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(CellStyle.BORDER_THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(CellStyle.BORDER_THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    styles.put("cell", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
    styles.put("formula", style);

    style = wb.createCellStyle();
    style.setAlignment(CellStyle.ALIGN_CENTER);
    style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_40_PERCENT.getIndex());
    style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    style.setDataFormat(wb.createDataFormat().getFormat("0.00"));
    styles.put("formula_2", style);

    return styles;
}

From source file:com.github.svrtm.xlreport.CellStyle_p.java

License:Apache License

public void copyTo(final CellStyle poiStyle) {
    if (verticalAlignment != null)
        poiStyle.setVerticalAlignment(verticalAlignment);
    if (alignment != null)
        poiStyle.setAlignment(alignment);

    if (borderBottom != null)
        poiStyle.setBorderBottom(borderBottom);
    if (bottomBorderColor != null)
        poiStyle.setBottomBorderColor(bottomBorderColor);
    if (borderLeft != null)
        poiStyle.setBorderLeft(borderLeft);
    if (leftBorderColor != null)
        poiStyle.setLeftBorderColor(leftBorderColor);
    if (borderRight != null)
        poiStyle.setBorderRight(borderRight);
    if (rightBorderColor != null)
        poiStyle.setRightBorderColor(rightBorderColor);
    if (borderTop != null)
        poiStyle.setBorderTop(borderTop);
    if (topBorderColor != null)
        poiStyle.setTopBorderColor(topBorderColor);

    if (wrapText != null)
        poiStyle.setWrapText(wrapText);

    if (fillPattern != null)
        poiStyle.setFillPattern(fillPattern);
    if (xssfFgColor == null) {
        if (fillForegroundColor != null)
            poiStyle.setFillForegroundColor(fillForegroundColor);
    } else/* w  ww .  j av a  2  s . c  om*/
        ((XSSFCellStyle) poiStyle).setFillForegroundColor(xssfFgColor);

    if (fmt != null)
        poiStyle.setDataFormat(fmt);
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private CellStyle getHeaderStyle(Workbook p_workbook) throws Exception {
    if (headerStyle == null) {
        Font font = p_workbook.createFont();
        font.setBoldweight(Font.BOLDWEIGHT_BOLD);
        font.setColor(IndexedColors.BLACK.getIndex());
        font.setUnderline(Font.U_NONE);
        font.setFontName("Times");
        font.setFontHeightInPoints((short) 11);

        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(font);/*from w  ww  . j  a va2s.  c  om*/
        cs.setWrapText(true);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderRight(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);
        cs.setBorderLeft(CellStyle.BORDER_THIN);

        headerStyle = cs;
    }

    return headerStyle;
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private CellStyle getContentStyle(Workbook p_workbook) throws Exception {
    if (contentStyle == null) {
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);/*  w  w w  .  j  a v  a2  s. c o m*/
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        contentStyle = style;
    }

    return contentStyle;
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private CellStyle getNoWrapContentStyle(Workbook p_workbook) throws Exception {
    if (noWrapContentStyle == null) {
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);//ww  w  . j av a 2s. c  o  m
        style.setWrapText(false);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        noWrapContentStyle = style;
    }

    return noWrapContentStyle;
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private CellStyle getRtlContentStyle(Workbook p_workbook) throws Exception {
    if (rtlContentStyle == null) {
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);/*from ww w .j  av a 2 s  .c  o m*/
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        rtlContentStyle = style;
    }

    return rtlContentStyle;
}

From source file:com.globalsight.everest.qachecks.DITAQAChecker.java

License:Apache License

private CellStyle getUnlockedStyle(Workbook p_workbook) throws Exception {
    if (unlockedStyle == null) {
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);//from ww  w. j  a  v  a 2s. c o m
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        unlockedStyle = style;
    }

    return unlockedStyle;
}

From source file:com.globalsight.everest.qachecks.QAChecker.java

License:Apache License

private CellStyle getContentStyle(Workbook p_workbook) {
    if (m_contentStyle == null) {
        CellStyle style = p_workbook.createCellStyle();
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);
        style.setFont(font);/*from ww w . jav a  2  s .c o  m*/

        m_contentStyle = style;
    }

    return m_contentStyle;
}