Example usage for org.apache.poi.xssf.usermodel XSSFCellStyle setShrinkToFit

List of usage examples for org.apache.poi.xssf.usermodel XSSFCellStyle setShrinkToFit

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFCellStyle setShrinkToFit.

Prototype

@Override
    public void setShrinkToFit(boolean shrinkToFit) 

Source Link

Usage

From source file:org.agmip.ui.afsirs.util.SummaryReportExcelFormat.java

private XSSFCellStyle getCellStyle(int type) {
    XSSFFont font = workbook.createFont();
    XSSFCellStyle style = null;

    switch (type) {
    case 1://from  www  .  j a  va 2 s.co m
        font.setFontHeightInPoints((short) 15);
        font.setFontName("IMPACT");
        font.setItalic(true);
        font.setColor(HSSFColor.BLUE.index);
        style = workbook.createCellStyle();
        style.setWrapText(true);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setFont(font);
        break;

    case 2:
        font.setFontHeightInPoints((short) 15);
        font.setFontName("IMPACT");
        font.setItalic(true);
        font.setColor(HSSFColor.BLUE.index);
        style = workbook.createCellStyle();
        style.setWrapText(true);
        style.setShrinkToFit(true);
        style.setFont(font);
        break;

    case 3:
        font.setFontHeightInPoints((short) 15);
        font.setFontName("IMPACT");
        font.setItalic(true);
        font.setColor(HSSFColor.BLUE.index);
        style = workbook.createCellStyle();
        style.setWrapText(true);
        style.setShrinkToFit(true);
        style.setFont(font);
        break;

    case 4:
        font.setFontHeightInPoints((short) 15);
        font.setFontName("IMPACT");
        font.setItalic(true);
        font.setColor(HSSFColor.BLUE.index);
        style = workbook.createCellStyle();
        style.setWrapText(true);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setFont(font);
        break;

    case 5:
        font.setFontHeightInPoints((short) 15);
        font.setFontName("IMPACT");
        font.setItalic(true);
        font.setColor(HSSFColor.BLUE.index);
        style = workbook.createCellStyle();
        style.setWrapText(true);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setFont(font);
        break;

    }

    return style;
}