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

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

Introduction

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

Prototype

void setDataFormat(short fmt);

Source Link

Document

set the data format (must be a valid format).

Usage

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.SummaryReportGenerator.java

License:Apache License

private CellStyle getFloatStyle(Workbook p_workbook) {
    if (floatStyle == null) {
        DataFormat formatDouble = p_workbook.createDataFormat();
        CellStyle cs = getCommonHeaderStyle(p_workbook);
        cs.setDataFormat(formatDouble.getFormat(DOUBLE_FORMAT));

        floatStyle = cs;//from w  w  w  .ja va 2  s .c  o  m
    }
    return floatStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.SummaryReportGenerator.java

License:Apache License

private CellStyle getFloatSumStyle(Workbook p_workbook) {
    if (floatSumStyle == null) {
        DataFormat formatDouble = p_workbook.createDataFormat();
        CellStyle cs = getCommonHeaderStyle(p_workbook);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
        cs.setDataFormat(formatDouble.getFormat(DOUBLE_FORMAT));

        floatSumStyle = cs;//  ww  w.j a va  2s .co  m
    }
    return floatSumStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.SummaryReportGenerator.java

License:Apache License

private CellStyle getMoneyStyle(Workbook p_workbook) {
    if (moneyStyle == null) {
        DataFormat moneyFormat = p_workbook.createDataFormat();
        CellStyle cs = getCommonHeaderStyle(p_workbook);
        cs.setDataFormat(moneyFormat.getFormat(moneyFormatString));

        moneyStyle = cs;/*  w  w  w.  j  a v  a2  s  .  c  o  m*/
    }
    return moneyStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.SummaryReportGenerator.java

License:Apache License

private CellStyle getMoneySumStyle(Workbook p_workbook) {
    if (moneySumStyle == null) {
        DataFormat moneyFormat = p_workbook.createDataFormat();
        CellStyle cs = getCommonHeaderStyle(p_workbook);
        cs.setDataFormat(moneyFormat.getFormat(moneyFormatString));
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.ORANGE.getIndex());

        moneySumStyle = cs;/*  ww  w  . j  a v a  2  s. c om*/
    }
    return moneySumStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.SummaryReportGenerator.java

License:Apache License

private CellStyle getPercentStyle(Workbook p_workbook) {
    if (percentStyle == null) {
        DataFormat percentFormat = p_workbook.createDataFormat();
        CellStyle cs = getCommonHeaderStyle(p_workbook);
        cs.setDataFormat(percentFormat.getFormat(PERCENT_FORMAT));

        percentStyle = cs;/*from w  ww. j av  a 2  s.  c  o  m*/
    }
    return percentStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.generator.SummaryReportGenerator.java

License:Apache License

private CellStyle getPercentSumStyle(Workbook p_workbook) {
    if (percentSumStyle == null) {
        DataFormat percentFormat = p_workbook.createDataFormat();

        CellStyle cs = getCommonHeaderStyle(p_workbook);
        cs.setDataFormat(percentFormat.getFormat(PERCENT_FORMAT));
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.ORANGE.getIndex());

        percentSumStyle = cs;/*  w w w .  j  a va2 s.  c o m*/
    }
    return percentSumStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerVendorPoXlsReportHelper.java

License:Apache License

private CellStyle getDateStyle(Workbook p_workbook) throws Exception {
    if (dateStyle == null) {
        Font defaultFont = p_workbook.createFont();
        defaultFont.setFontName("Arial");
        defaultFont.setFontHeightInPoints((short) 10);

        DataFormat format = p_workbook.createDataFormat();
        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(defaultFont);/*from   w ww  .  j a  v  a2  s  .c om*/
        cs.setDataFormat(format.getFormat(DEFAULT_DATE_FORMAT));
        cs.setWrapText(false);

        dateStyle = cs;
    }

    return dateStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerVendorPoXlsReportHelper.java

License:Apache License

private CellStyle getMoneyStyle(Workbook p_workbook) throws Exception {
    if (moneyStyle == null) {
        Font defaultFont = p_workbook.createFont();
        defaultFont.setFontName("Arial");
        defaultFont.setFontHeightInPoints((short) 10);

        DataFormat euroNumberFormat = p_workbook.createDataFormat();
        CellStyle cs = p_workbook.createCellStyle();
        cs.setFont(defaultFont);/*from  ww w.  j  a  v a2 s .c  om*/
        cs.setWrapText(false);
        cs.setDataFormat(euroNumberFormat.getFormat(CurrencyThreadLocal.getMoneyFormatString()));

        moneyStyle = cs;
    }

    return moneyStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.ReviewerVendorPoXlsReportHelper.java

License:Apache License

private CellStyle getTotalMoneyStyle(Workbook p_workbook) throws Exception {
    if (totalMoneyStyle == null) {
        DataFormat euroNumberFormat = p_workbook.createDataFormat();
        CellStyle cs = p_workbook.createCellStyle();
        cs.setDataFormat(euroNumberFormat.getFormat(CurrencyThreadLocal.getMoneyFormatString()));
        cs.setWrapText(false);/* w  w  w  .j ava2  s . com*/
        cs.setBorderTop(CellStyle.BORDER_THIN);
        cs.setBorderBottom(CellStyle.BORDER_THIN);
        cs.setFillPattern(CellStyle.SOLID_FOREGROUND);
        cs.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());

        totalMoneyStyle = cs;
    }

    return totalMoneyStyle;
}

From source file:com.globalsight.everest.webapp.pagehandler.administration.reports.TranslationProgressReportHelper.java

License:Apache License

private CellStyle getPercentStyle(Workbook p_workbook) throws Exception {
    if (percentStyle == null) {
        DataFormat format = p_workbook.createDataFormat();
        CellStyle style = p_workbook.createCellStyle();
        Font font = p_workbook.createFont();
        font.setFontName("Arial");
        font.setFontHeightInPoints((short) 10);
        style.setDataFormat(format.getFormat("0%"));
        style.setFont(font);//w ww .  ja v  a 2 s.  c om
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);

        percentStyle = style;
    }

    return percentStyle;
}