Example usage for org.apache.poi.ss.usermodel VerticalAlignment CENTER

List of usage examples for org.apache.poi.ss.usermodel VerticalAlignment CENTER

Introduction

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

Prototype

VerticalAlignment CENTER

To view the source code for org.apache.poi.ss.usermodel VerticalAlignment CENTER.

Click Source Link

Document

The vertical alignment is centered across the height of the cell.

Usage

From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerColorImpl.java

License:Apache License

@Override
public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) {
    CellStyle style = workbook.createCellStyle();
    style.setBorderLeft(BorderStyle.THIN);
    style.setBorderRight(BorderStyle.THIN);
    style.setBorderBottom(BorderStyle.THIN);
    style.setBorderTop(BorderStyle.THIN);
    style.setFillForegroundColor((short) 41);
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setDataFormat(STRING_FORMAT);//from   w  w  w. j av  a2  s. co m
    if (isWarp) {
        style.setWrapText(true);
    }
    return style;
}

From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl.java

License:Apache License

@Override
public CellStyle getTitleStyle(short color) {
    CellStyle titleStyle = workbook.createCellStyle();
    titleStyle.setAlignment(HorizontalAlignment.CENTER);
    titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    titleStyle.setWrapText(true);//from   ww  w .j  a v a2 s. com
    return titleStyle;
}

From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl.java

License:Apache License

@Override
public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) {
    CellStyle style = workbook.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setDataFormat(STRING_FORMAT);/*from  www.j  a v  a 2  s . com*/
    if (isWarp) {
        style.setWrapText(true);
    }
    return style;
}

From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl.java

License:Apache License

@Override
public CellStyle getHeaderStyle(short color) {
    CellStyle titleStyle = workbook.createCellStyle();
    Font font = workbook.createFont();
    font.setFontHeightInPoints((short) 12);
    titleStyle.setFont(font);//from   ww  w  .j a  v a  2 s .  com
    titleStyle.setAlignment(HorizontalAlignment.CENTER);
    titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    return titleStyle;
}

From source file:cn.afterturn.easypoi.excel.export.styler.ExcelExportStylerDefaultImpl.java

License:Apache License

@Override
public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) {
    CellStyle style = workbook.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setDataFormat(STRING_FORMAT);/*from  w w  w.  j a v  a 2 s. c  om*/
    if (isWarp) {
        style.setWrapText(true);
    }
    return style;
}

From source file:cn.com.zhbook.component.poi.PoiPerformanceTest.java

License:Apache License

static Map<String, CellStyle> createStyles(Workbook wb) {
    Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
    CellStyle style;//  ww  w .  j a  v a  2s .c o m

    Font headerFont = wb.createFont();
    headerFont.setFontHeightInPoints((short) 14);
    headerFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFont(headerFont);
    style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    styles.put("header", style);

    Font monthFont = wb.createFont();
    monthFont.setFontHeightInPoints((short) 12);
    monthFont.setColor(IndexedColors.RED.getIndex());
    monthFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(monthFont);
    styles.put("red-bold", style);

    String[] nfmt = { "#,##0.00", "$#,##0.00", "m/d/yyyy" };
    for (String fmt : nfmt) {
        style = wb.createCellStyle();
        style.setDataFormat(wb.createDataFormat().getFormat(fmt));
        styles.put(fmt, style);
    }

    return styles;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloProveedor(Workbook wb) {
    CellStyle estiloCelda = wb.createCellStyle();
    Font fuente = wb.createFont();
    fuente.setFontName("Calibri");
    fuente.setBold(true);//  ww  w .j  a  va2  s  .  c o m
    fuente.setFontHeightInPoints((short) 32);
    fuente.setColor(IndexedColors.ROYAL_BLUE.getIndex());
    estiloCelda.setFont(fuente);
    estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    estiloCelda.setAlignment(HorizontalAlignment.CENTER);

    return estiloCelda;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloColumnas(Workbook wb, int tipo) {
    CellStyle estiloCelda = wb.createCellStyle();
    Font fuente = wb.createFont();
    if (tipo == COLUMNA) {
        estiloCelda.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
        fuente.setBold(true);/*from   w  w  w . j  av a2  s.  c o  m*/
    }
    if (tipo == SURTIDO) {
        fuente.setColor(IndexedColors.WHITE.getIndex());
        estiloCelda.setFillForegroundColor(IndexedColors.ROYAL_BLUE.getIndex());
        estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
    }
    fuente.setFontName("Calibri");
    fuente.setFontHeightInPoints((short) 11);
    estiloCelda.setFont(fuente);
    estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    estiloCelda.setAlignment(HorizontalAlignment.CENTER);
    if (tipo == COLUMNA) {
        estiloCelda.setBorderBottom(BorderStyle.MEDIUM);
        estiloCelda.setBorderTop(BorderStyle.MEDIUM);
        estiloCelda.setBorderLeft(BorderStyle.MEDIUM);
        estiloCelda.setBorderRight(BorderStyle.MEDIUM);
    } else {
        estiloCelda.setBorderBottom(BorderStyle.THIN);
        estiloCelda.setBorderTop(BorderStyle.THIN);
        estiloCelda.setBorderLeft(BorderStyle.THIN);
        estiloCelda.setBorderRight(BorderStyle.THIN);
    }
    return estiloCelda;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloTotales(Workbook wb) {
    CellStyle estiloCelda = wb.createCellStyle();
    Font fuente = wb.createFont();
    estiloCelda.setFillForegroundColor(IndexedColors.ROYAL_BLUE.getIndex());
    estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
    fuente.setFontName("Calibri");
    fuente.setBold(true);//www .j a  va  2  s .co  m
    fuente.setFontHeightInPoints((short) 14);
    fuente.setColor(IndexedColors.WHITE.getIndex());
    estiloCelda.setFont(fuente);
    estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    estiloCelda.setAlignment(HorizontalAlignment.CENTER);
    estiloCelda.setBorderBottom(BorderStyle.MEDIUM);
    estiloCelda.setBorderTop(BorderStyle.MEDIUM);
    estiloCelda.setBorderLeft(BorderStyle.MEDIUM);
    estiloCelda.setBorderRight(BorderStyle.MEDIUM);

    return estiloCelda;
}

From source file:com.catexpress.util.FormatosPOI.java

public CellStyle estiloCuadro(Workbook wb, int tipo) {
    CellStyle estiloCelda = wb.createCellStyle();
    Font fuente = wb.createFont();
    if (tipo == AMARILLO) {
        estiloCelda.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
        estiloCelda.setFillPattern(CellStyle.SOLID_FOREGROUND);
    }/*w w w .j av  a2s  .  c  o  m*/
    fuente.setFontName("Calibri");
    fuente.setBold(true);
    fuente.setFontHeightInPoints((short) 12);
    estiloCelda.setFont(fuente);
    estiloCelda.setVerticalAlignment(VerticalAlignment.CENTER);
    estiloCelda.setAlignment(HorizontalAlignment.CENTER);
    estiloCelda.setBorderBottom(BorderStyle.THIN);
    estiloCelda.setBorderTop(BorderStyle.THIN);
    estiloCelda.setBorderLeft(BorderStyle.THIN);
    estiloCelda.setBorderRight(BorderStyle.THIN);

    return estiloCelda;
}