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

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

Introduction

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

Prototype

void setAlignment(HorizontalAlignment align);

Source Link

Document

set the type of horizontal alignment for the cell

Usage

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

License:Apache License

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

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);//from w  w w .j a v  a 2 s  . co m
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);

        iceUnlockedStyle = style;
    }

    return iceUnlockedStyle;
}

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

License:Apache License

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

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);// w  w  w.ja  va  2 s . c om
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);

        exactUnlockedStyle = style;
    }

    return exactUnlockedStyle;
}

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

License:Apache License

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

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);/*w w  w  . ja  v  a  2 s.co m*/
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);

        unlockedRightStyle = style;
    }

    return unlockedRightStyle;
}

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

License:Apache License

private CellStyle getIceUnlockedRightStyle(Workbook p_workbook) throws Exception {
    if (iceUnlockedRightStyle == 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  av  a2 s. c  o  m
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);

        iceUnlockedRightStyle = style;
    }

    return iceUnlockedRightStyle;
}

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

License:Apache License

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

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);//from w  w  w .  jav a2 s . co  m
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setFillPattern(CellStyle.SOLID_FOREGROUND);
        style.setFillForegroundColor(IndexedColors.PALE_BLUE.getIndex());
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);

        exactUnlockedRightStyle = style;
    }

    return exactUnlockedRightStyle;
}

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

License:Apache License

private CellStyle getContentStyle(Workbook p_workbook) {
    if (contentStyle == null) {
        CellStyle style = p_workbook.createCellStyle();
        style.setWrapText(true);//from  w  ww.ja  v a 2 s.c o  m
        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);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        contentStyle = style;
    }

    return contentStyle;
}

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

License:Apache License

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

        CellStyle style = p_workbook.createCellStyle();
        style.setFont(font);/*from w  w  w  . j a  v  a2 s.  c  o m*/
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        rtlContentStyle = style;
    }

    return rtlContentStyle;
}

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

License:Apache License

private CellStyle getUnlockedStyle(Workbook p_workbook) {
    if (unlockedStyle == 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 va  2 s . c  o  m
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_LEFT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        unlockedStyle = style;
    }

    return unlockedStyle;
}

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

License:Apache License

private CellStyle getUnlockedRightStyle(Workbook p_workbook) {
    if (unlockedRightStyle == 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  va2s  .  c  o  m
        style.setLocked(false);
        style.setWrapText(true);
        style.setAlignment(CellStyle.ALIGN_RIGHT);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
        style.setBorderTop(CellStyle.BORDER_THIN);
        style.setBorderRight(CellStyle.BORDER_THIN);
        style.setBorderBottom(CellStyle.BORDER_THIN);
        style.setBorderLeft(CellStyle.BORDER_THIN);
        style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);

        unlockedRightStyle = style;
    }

    return unlockedRightStyle;
}

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

License:Apache License

/**
 * Creates Monthly Sheet//  w w w.jav  a 2s  .co m
 */
private void createMonthlySheet(Workbook p_workbook, Sheet p_sheet, ReportSearchOptions p_options,
        Map<String, ReportWordCount> p_wordCounts) throws Exception {
    List<String> searchMonths = p_options.getMonths();

    CellStyle style = getHeaderStyle(p_workbook);

    CellStyle style1 = getHeaderStyle(p_workbook, null, null, null, null);

    CellStyle styleTB = getHeaderStyle(p_workbook, CellStyle.BORDER_THIN, null, CellStyle.BORDER_THIN, null);

    CellStyle styleTB2 = getHeaderStyle(p_workbook, CellStyle.BORDER_THIN, null, CellStyle.BORDER_THIN, null);
    styleTB2.setAlignment(CellStyle.ALIGN_RIGHT);

    CellStyle styleLR = getHeaderStyle(p_workbook, null, CellStyle.BORDER_THIN, null, CellStyle.BORDER_THIN);

    int row = ROWNUMBER, column = 0;

    p_sheet.setColumnWidth(0, 12 * 256);

    Cell cell_A_Header = getCell(getRow(p_sheet, row), column++);
    cell_A_Header.setCellValue(bundle.getString("lb_sumOfTotal"));
    cell_A_Header.setCellStyle(style);
    p_sheet.addMergedRegion(new CellRangeAddress(row, row, column, column + searchMonths.size()));
    setRegionStyle(p_sheet, new CellRangeAddress(row, row, column, column + searchMonths.size()), style);
    Cell cell_B_Header = getCell(getRow(p_sheet, row), column);
    cell_B_Header.setCellValue(bundle.getString("lb_month"));
    cell_B_Header.setCellStyle(style);

    row++;
    column = 0;
    Cell cell_A = getCell(getRow(p_sheet, row), column++);
    cell_A.setCellValue(bundle.getString("lb_lang"));
    cell_A.setCellStyle(style);
    for (String yearAndMonth : searchMonths) {
        Cell cell_Month = getCell(getRow(p_sheet, row), column++);
        cell_Month.setCellValue(Double.valueOf(yearAndMonth.substring(4)));
        cell_Month.setCellStyle(styleTB);
    }
    p_sheet.setColumnWidth(column, 10 * 256);
    Cell cell_LocaleTotal = getCell(getRow(p_sheet, row), column++);
    cell_LocaleTotal.setCellValue(bundle.getString("lb_grandTotal"));
    cell_LocaleTotal.setCellStyle(style);

    // Adds a hidden column, for Excel Sum Check Error.
    Row hiddenRow = getRow(p_sheet, ++row);
    hiddenRow.setZeroHeight(isHidden);
    getRow(p_sheet, row - 1).setHeight(p_sheet.getDefaultRowHeight());

    int dataRow = ++row;
    column = 0;
    double totalWordCount = 0;
    Set<String> locales = getLocals(p_wordCounts);
    for (String locale : locales) {
        Cell cell_A_Locale = getCell(getRow(p_sheet, row), column++);
        cell_A_Locale.setCellValue(locale);
        cell_A_Locale.setCellStyle(styleLR);
        for (String yearAndMonth : searchMonths) {
            ReportWordCount reportWordCount = p_wordCounts.get(getWordCountMapKey(locale, yearAndMonth));
            if (reportWordCount != null) {
                totalWordCount = reportWordCount.getTradosTotalWordCount();
            }
            addNumberCell(p_sheet, column++, row, totalWordCount, style1);
            totalWordCount = 0;
        }
        Cell cell_LocaleTotal_Month = getCell(getRow(p_sheet, row), column);
        cell_LocaleTotal_Month.setCellFormula(getSumOfRow(1, column - 1, row));
        cell_LocaleTotal_Month.setCellStyle(styleLR);
        row++;
        column = 0;
    }

    if (row > (ROWNUMBER + 3)) {
        column = 0;
        Cell cell_GrandTotal = getCell(getRow(p_sheet, row), column++);
        cell_GrandTotal.setCellValue(bundle.getString("lb_grandTotal"));
        cell_GrandTotal.setCellStyle(style);
        for (int i = 0; i < searchMonths.size(); i++) {
            Cell cell_MonthTotal = getCell(getRow(p_sheet, row), column);
            cell_MonthTotal.setCellFormula(getSumOfColumn(dataRow, row - 1, column));
            cell_MonthTotal.setCellStyle(styleTB);
            column++;
        }
        Cell cell_Total = getCell(getRow(p_sheet, row), column);
        cell_Total.setCellFormula(getSumOfColumn(dataRow, row - 1, column));
        cell_Total.setCellStyle(style);
    }
}