Java 类org.apache.poi.ss.usermodel.HorizontalAlignment 实例源码

项目:vaadin-gridexport    文件:ExcelExport.java   
/**
 * Returns the default data cell style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultDataCellStyle(final Workbook wb) {
    CellStyle style;
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setWrapText(true);
    style.setBorderRight(BorderStyle.THIN);
    style.setRightBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderLeft(BorderStyle.THIN);
    style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderTop(BorderStyle.THIN);
    style.setTopBorderColor(IndexedColors.BLACK.getIndex());
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
    style.setDataFormat(doubleDataFormat);
    return style;
}
项目:vaadin-gridexport    文件:ExcelExport.java   
protected void setupTotalCell(Cell cell, final String propId, final int currentRow, final int startRow, int col) {
    cell.setCellStyle(getCellStyle(propId, currentRow, startRow, col, true));
    final HorizontalAlignment poiAlignment = getGridHolder().getCellAlignment(propId);
    CellUtil.setAlignment(cell, poiAlignment);
    Class<?> propType = getGridHolder().getPropertyType(propId);
    if (isNumeric(propType)) {
        CellRangeAddress cra = new CellRangeAddress(startRow, currentRow - 1, col, col);
        if (isHierarchical()) {
            // 9 & 109 are for sum. 9 means include hidden cells, 109 means exclude.
            // this will show the wrong value if the user expands an outlined category, so
            // we will range value it first
            cell.setCellFormula("SUM(" + cra.formatAsString(hierarchicalTotalsSheet.getSheetName(),
                    true) + ")");
        } else {
            cell.setCellFormula("SUM(" + cra.formatAsString() + ")");
        }
    } else {
        if (0 == col) {
            cell.setCellValue(createHelper.createRichTextString("Total"));
        }
    }
}
项目:vaadin-gridexport    文件:ExcelExport.java   
/**
 * Returns the default title style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultTitleCellStyle(final Workbook wb) {
    CellStyle style;
    final Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short) 18);
    titleFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFont(titleFont);
    return style;
}
项目:vaadin-gridexport    文件:ExcelExport.java   
/**
 * Returns the default header style. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultHeaderCellStyle(final Workbook wb) {
    CellStyle style;
    final Font monthFont = wb.createFont();
    monthFont.setFontHeightInPoints((short) 11);
    monthFont.setColor(IndexedColors.WHITE.getIndex());
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(monthFont);
    style.setWrapText(true);
    return style;
}
项目:bdf2    文件:GridStyleBuilder.java   
public CellStyle createIndentationCellStyle(Workbook workbook, int s) {
    CellStyle dataStyle1 = this.createBorderCellStyle(workbook, true);
    Font dataFont = workbook.createFont();
    dataFont.setColor((short) 12);
    dataFont.setFontHeightInPoints((short) 10);
    dataStyle1.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    dataStyle1.setFillForegroundColor((short) 11);
    dataStyle1.setFont(dataFont);
    dataStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
    dataStyle1.setAlignment(HorizontalAlignment.LEFT);
    dataStyle1.setIndention(Short.valueOf(String.valueOf((s))));
    return dataStyle1;
}
项目:bdf2    文件:TitleStyleBuilder.java   
private HSSFCellStyle createHSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) {
    HSSFWorkbook workbook = (HSSFWorkbook) wb;
    HSSFPalette palette = workbook.getCustomPalette();

    palette.setColorAtIndex((short) 9, (byte) fontColor[0], (byte) fontColor[1], (byte) fontColor[2]);
    palette.setColorAtIndex((short) 10, (byte) bgColor[0], (byte) bgColor[1], (byte) bgColor[2]);

    HSSFFont titleFont = workbook.createFont();
    titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
    titleFont.setFontName("宋体");
    titleFont.setColor((short) 9);
    titleFont.setBold(true); 
    titleFont.setFontHeightInPoints((short) fontSize);

    HSSFCellStyle titleStyle = (HSSFCellStyle) createBorderCellStyle(workbook, true);
    titleStyle.setFont(titleFont);
    titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    titleStyle.setFillForegroundColor((short) 10);
    titleStyle.setAlignment(HorizontalAlignment.CENTER);
    titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);

    return titleStyle;
}
项目:vaadin-gridexport    文件:ExcelExport.java   
/**
 * Adds the header row. Override this method to change header-row-related
 * aspects of the workbook. Alternately, the header Row Object is accessible
 * via getHeaderRow() after report creation. To change header CellStyle,
 * though, use setHeaderStyle().
 *
 * @param row the row
 */
protected void addHeaderRow(final int row) {
    headerRow = sheet.createRow(row);
    Cell headerCell;
    headerRow.setHeightInPoints(40);
    int col = 0;
    for (final String propId : getPropIds()) {
        headerCell = headerRow.createCell(col);
        headerCell.setCellValue(createHelper.createRichTextString(getGridHolder().getColumnHeader(propId)));
        headerCell.setCellStyle(getColumnHeaderStyle(row, col));

        final HorizontalAlignment poiAlignment = getGridHolder().getCellAlignment(propId);
        CellUtil.setAlignment(headerCell, poiAlignment);
        col++;
    }
}
项目:jasperreports    文件:JRXlsExporter.java   
protected HSSFCellStyle getLoadedCellStyle(
    FillPatternType mode,
    short backcolor,
    HorizontalAlignment horizontalAlignment,
    VerticalAlignment verticalAlignment,
    short rotation,
    HSSFFont font,
    BoxStyle box,
    boolean isWrapText,
    boolean isCellLocked,
    boolean isCellHidden,
    boolean isShrinkToFit
    )
{
    StyleInfo style = new StyleInfo(mode, backcolor, horizontalAlignment, verticalAlignment, rotation, font, box, isWrapText, isCellLocked, isCellHidden, isShrinkToFit);
    return getLoadedCellStyle(style);
}
项目:jasperreports    文件:JRXlsExporter.java   
public StyleInfo(
    FillPatternType mode,
    short backcolor,
    HorizontalAlignment horizontalAlignment,
    VerticalAlignment verticalAlignment,
    short rotation,
    HSSFFont font,
    JRExporterGridCell gridCell,
    boolean wrapText,
    boolean cellLocked,
    boolean cellHidden,
    boolean shrinkToFit
    )
{
    this(mode, 
        backcolor, 
        horizontalAlignment, 
        verticalAlignment, 
        rotation, 
        font, 
        (gridCell == null ? null : new BoxStyle(gridCell)), 
        wrapText, 
        cellLocked, 
        cellHidden, 
        shrinkToFit);
}
项目:phone    文件:ExcelExportSuper.java   
/**
 * 表头条件
 * @param sheet
 * @param t
 * @param cellCount
 * @return
 */
void writeCondtions(HSSFSheet sheet){
    T t = getConditions();
    if (t!=null) {
        HSSFRow row = sheet.createRow(getRowNumber());
        row.setHeight((short) 500);
        CellRangeAddress cra = new CellRangeAddress(getRowNumber(), getRowNumber(), 0, getColumnJson().size());
        sheet.addMergedRegion(cra);
        HSSFCell cell = row.createCell(0);
        HSSFCellStyle style = cell.getCellStyle();
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        style.setWrapText(true);
        cell.setCellStyle(style);
        setCellValue(cell, formatCondition(t));
        addRowNumber();
    }
}
项目:CCDA-Score-CARD    文件:ScorecardExcelGenerator.java   
public static HSSFCellStyle createCellStyleForColumnHeading(HSSFWorkbook workBook) {
    HSSFCellStyle cellStyle = workBook.createCellStyle();
    HSSFFont fontObj = workBook.createFont();
    cellStyle.setBorderBottom(BorderStyle.THIN);
    cellStyle.setBorderTop(BorderStyle.THIN);
    cellStyle.setBorderLeft(BorderStyle.THIN);
    cellStyle.setBorderRight(BorderStyle.THIN);
    cellStyle.setWrapText(true);
    cellStyle.setAlignment(HorizontalAlignment.CENTER);
    cellStyle.setFillBackgroundColor(Short.valueOf("22").shortValue());
    cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);
    cellStyle.setFillForegroundColor(Short.valueOf("22").shortValue());
    cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    fontObj.setFontName("Calibri");
    fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
    fontObj.setBold(true);
    fontObj.setColor(Short.valueOf("8").shortValue());
    cellStyle.setFont(fontObj);
    return cellStyle;
}
项目:meja    文件:PoiHelper.java   
public static HorizontalAlignment hAlignToPoi(HAlign hAlign) {
    switch (hAlign) {
    case ALIGN_LEFT:
        return HorizontalAlignment.LEFT;
    case ALIGN_RIGHT:
        return HorizontalAlignment.RIGHT;
    case ALIGN_CENTER:
        return HorizontalAlignment.CENTER;
    case ALIGN_JUSTIFY:
        return HorizontalAlignment.JUSTIFY;
    case ALIGN_AUTOMATIC:
        return HorizontalAlignment.GENERAL;
    default:
        throw new IllegalArgumentException();
    }
}
项目:meja    文件:PoiHelper.java   
public static HAlign poiToHAlign(HorizontalAlignment alignment) {
    switch (alignment) {
    case LEFT:
        return HAlign.ALIGN_LEFT;
    case CENTER:
        return HAlign.ALIGN_CENTER;
    case RIGHT:
        return HAlign.ALIGN_RIGHT;
    case CENTER_SELECTION:
        return HAlign.ALIGN_CENTER;
    case GENERAL:
        return HAlign.ALIGN_AUTOMATIC;
    default:
        return HAlign.ALIGN_JUSTIFY;
    }
}
项目:alfresco-benchmark    文件:XLSXReporter.java   
/**
 * Creates a new line with values in the sheet.
 * 
 * @param workbook
 *            (XSSFWorkbook, required) workbook to create the row in
 * @param sheetRow
 *            (XSSFSheetRow, required) sheet to create the data row in
 * @param sheetName
 *            (String, required) name of the sheet
 * @param values
 *            (String [], optional) if null or empty no work will be done, else the values written to the next line
 * @param bold
 *            (boolean) true: the values will be set in bold font face, else normal
 * 
 * @since 2.0.10
 */
private void createSheetRow(XSSFWorkbook workbook, XSSFSheetRow sheetRow, String sheetName, List<String> values,
        boolean bold)
{
    if (null != values && values.size() > 0)
    {
        // check if sheet exists and create if not
        if (null == sheetRow.sheet)
        {
            sheetRow.sheet = workbook.createSheet(sheetName);
        }

        // create cell style
        XSSFCellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setAlignment(HorizontalAlignment.CENTER);

        if (bold)
        {
            // Create bold font
            Font fontBold = workbook.createFont();
            fontBold.setBoldweight(Font.BOLDWEIGHT_BOLD);
            cellStyle.setFont(fontBold);
        }

        // create row
        XSSFRow row = sheetRow.sheet.createRow(sheetRow.rowCount++);

        // set values
        for (int i = 0; i < values.size(); i++)
        {
            row.getCell(i).setCellValue(values.get(i));
            row.getCell(i).setCellStyle(cellStyle);
        }
    }
}
项目:vaadin-gridexport    文件:DefaultGridHolder.java   
@Override
public HorizontalAlignment getCellAlignment(final String propId) {
    final Renderer<?> renderer = getRenderer(propId);
    if (renderer != null) {
        if (ExcelExport.isNumeric(renderer.getPresentationType())) {
            return HorizontalAlignment.RIGHT;
        }
    }
    return defaultAlignment;
}
项目:vaadin-gridexport    文件:ExcelExport.java   
/**
 * Returns the default totals row style for Double data. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultTotalsDoubleCellStyle(final Workbook wb) {
    CellStyle style;
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setDataFormat(doubleDataFormat);
    return style;
}
项目:vaadin-gridexport    文件:ExcelExport.java   
/**
 * Returns the default totals row style for Integer data. Obtained from:
 * http://svn.apache.org/repos/asf/poi
 * /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
 *
 * @param wb the wb
 * @return the cell style
 */
protected CellStyle defaultTotalsIntegerCellStyle(final Workbook wb) {
    CellStyle style;
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setDataFormat(integerDataFormat);
    return style;
}
项目:bdf2    文件:AbstractStyleBuilder.java   
public void setCellStyleAligment(CellStyle style, int i) {
    if (i == 0) {
        style.setAlignment(HorizontalAlignment.LEFT);
    } else if (i == 1) {
        style.setAlignment(HorizontalAlignment.CENTER);
    } else if (i == 2) {
        style.setAlignment(HorizontalAlignment.RIGHT);
    }
}
项目:bdf2    文件:TitleStyleBuilder.java   
private XSSFCellStyle createXSSFCellStyle(Workbook wb, int[] bgColor, int[] fontColor, int fontSize) {
    SXSSFWorkbook workbook = (SXSSFWorkbook) wb;
    XSSFFont titleFont = (XSSFFont) workbook.createFont();
    titleFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
    titleFont.setFontName("宋体");

    XSSFColor color9 = new XSSFColor(new java.awt.Color(fontColor[0], fontColor[1], fontColor[2]));
    XSSFColor color10 = new XSSFColor(new java.awt.Color(bgColor[0], bgColor[1], bgColor[2]));

    if (!(fontColor[0] == 0 && fontColor[1] == 0 && fontColor[2] == 0)) {
        titleFont.setColor(color9);
    }
    titleFont.setBold(true);
    titleFont.setFontHeightInPoints((short) fontSize);

    XSSFCellStyle titleStyle = (XSSFCellStyle) createBorderCellStyle(workbook, true);
    titleStyle.setFont(titleFont);
    titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    titleStyle.setFillForegroundColor(color10);
    titleStyle.setAlignment(HorizontalAlignment.CENTER);
    titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);

    return titleStyle;
}
项目:excel2javabeans    文件:ExcelBeanFieldParser.java   
private CellStyle createAlign(ExcelColStyle colStyle) {
    var style = sheet.getWorkbook().createCellStyle();
    val align = colStyle.align();
    if (align == ExcelColAlign.LEFT) {
        style.setAlignment(HorizontalAlignment.LEFT);
    } else if (align == ExcelColAlign.CENTER) {
        style.setAlignment(HorizontalAlignment.CENTER);
    } else if (align == ExcelColAlign.RIGHT) {
        style.setAlignment(HorizontalAlignment.RIGHT);
    } else {
        style = null;
    }

    return style;
}
项目:jasperreports    文件:JRXlsExporter.java   
@Override
protected void addBlankCell(JRExporterGridCell gridCell, int colIndex, int rowIndex)
{
    cell = row.createCell(colIndex);

    FillPatternType mode = backgroundMode;
    short backcolor = whiteIndex;

    if (!Boolean.TRUE.equals(sheetInfo.ignoreCellBackground) && gridCell.getCellBackcolor() != null)
    {
        mode = FillPatternType.SOLID_FOREGROUND;
        backcolor = getWorkbookColor(gridCell.getCellBackcolor()).getIndex();
    }

    short forecolor = blackIndex;
    if (gridCell.getForecolor() != null)
    {
        forecolor = getWorkbookColor(gridCell.getForecolor()).getIndex();
    }

    HSSFCellStyle cellStyle =
        getLoadedCellStyle(
            mode,
            backcolor,
            HorizontalAlignment.LEFT,
            VerticalAlignment.TOP,
            (short)0,
            getLoadedFont(getDefaultFont(), forecolor, null, getLocale()),
            gridCell,
            true, 
            true, 
            false, 
            false
            );

    cell.setCellStyle(cellStyle);
}
项目:jasperreports    文件:JRXlsExporter.java   
@Override
protected void exportRectangle(JRPrintGraphicElement element, JRExporterGridCell gridCell, int colIndex, int rowIndex)
{
    short forecolor = getWorkbookColor(element.getLinePen().getLineColor()).getIndex();

    FillPatternType mode = backgroundMode;
    short backcolor = whiteIndex;
    if (!Boolean.TRUE.equals(sheetInfo.ignoreCellBackground) && gridCell.getCellBackcolor() != null)
    {
        mode = FillPatternType.SOLID_FOREGROUND;
        backcolor = getWorkbookColor(gridCell.getCellBackcolor()).getIndex();
    }

    HSSFCellStyle cellStyle =
        getLoadedCellStyle(
            mode,
            backcolor,
            HorizontalAlignment.LEFT,
            VerticalAlignment.TOP,
            (short)0,
            getLoadedFont(getDefaultFont(), forecolor, null, getLocale()),
            gridCell,
            isWrapText(element),
            isCellLocked(element),
            isCellHidden(element),
            isShrinkToFit(element)
            );

    createMergeRegion(gridCell, colIndex, rowIndex, cellStyle);

    cell = row.createCell(colIndex);
    cell.setCellStyle(cellStyle);
}
项目:jasperreports    文件:JRXlsExporter.java   
private HorizontalAlignment getHorizontalAlignment(TextAlignHolder alignment)
{
    switch (alignment.horizontalAlignment)
    {
        case RIGHT:
            return HorizontalAlignment.RIGHT;
        case CENTER:
            return HorizontalAlignment.CENTER;
        case JUSTIFIED:
            return HorizontalAlignment.JUSTIFY;
        case LEFT:
        default:
            return HorizontalAlignment.LEFT;
    }
}
项目:jasperreports    文件:JRXlsExporter.java   
protected HSSFCellStyle getLoadedCellStyle(
    FillPatternType mode,
    short backcolor,
    HorizontalAlignment horizontalAlignment,
    VerticalAlignment verticalAlignment,
    short rotation,
    HSSFFont font,
    JRExporterGridCell gridCell,
    boolean isWrapText,
    boolean isCellLocked,
    boolean isCellHidden,
    boolean isShrinkToFit
    )
{
    return getLoadedCellStyle(
        new StyleInfo(
            mode, 
            backcolor, 
            horizontalAlignment, 
            verticalAlignment, 
            rotation, 
            font, 
            gridCell, 
            isWrapText, 
            isCellLocked, 
            isCellHidden, 
            isShrinkToFit));
}
项目:jasperreports    文件:JRXlsExporter.java   
@Override
protected void exportFrame(JRPrintFrame frame, JRExporterGridCell gridCell, int x, int y)
{
    FillPatternType mode = backgroundMode;
    short backcolor = whiteIndex;
    if (frame.getModeValue() == ModeEnum.OPAQUE)
    {
        mode = FillPatternType.SOLID_FOREGROUND;
        backcolor = getWorkbookColor(frame.getBackcolor()).getIndex();
    }

    short forecolor = getWorkbookColor(frame.getForecolor()).getIndex();

    HSSFCellStyle cellStyle =
        getLoadedCellStyle(
            mode,
            backcolor,
            HorizontalAlignment.LEFT,
            VerticalAlignment.TOP,
            (short)0,
            getLoadedFont(getDefaultFont(), forecolor, null, getLocale()),
            gridCell,
            isWrapText(frame),
            isCellLocked(frame),
            isCellHidden(frame),
            isShrinkToFit(frame)
            );

    createMergeRegion(gridCell, x, y, cellStyle);

    cell = row.createCell(x);
    cell.setCellStyle(cellStyle);
}
项目:jasperreports    文件:JRXlsExporter.java   
public StyleInfo(
    FillPatternType mode,
    short backcolor,
    HorizontalAlignment horizontalAlignment,
    VerticalAlignment verticalAlignment,
    short rotation,
    HSSFFont font,
    BoxStyle box,
    boolean wrapText,
    boolean cellLocked,
    boolean cellHidden,
    boolean shrinkToFit
    )
{
    this.mode = mode;
    this.backcolor = backcolor;
    this.horizontalAlignment = horizontalAlignment;
    this.verticalAlignment = verticalAlignment;
    this.rotation = rotation;
    this.font = font;

    this.box = box;
    this.lcWrapText = shrinkToFit ? false : wrapText;
    this.lcCellLocked = cellLocked;
    this.lcCellHidden = cellHidden;
    this.lcShrinkToFit = shrinkToFit;
    hashCode = computeHash();
}
项目:jasperreports    文件:JRXlsMetadataExporter.java   
@Override
protected void exportRectangle(JRPrintGraphicElement element) throws JRException {
    String currentColumnName = element.getPropertiesMap().getProperty(JRXlsAbstractMetadataExporter.PROPERTY_COLUMN_NAME);

    if (currentColumnName != null && currentColumnName.length() > 0) {
        boolean repeatValue = getPropertiesUtil().getBooleanProperty(element, JRXlsAbstractMetadataExporter.PROPERTY_REPEAT_VALUE, false);

        setColumnName(currentColumnName);
        adjustColumnWidth(currentColumnName, element.getWidth(), ((JRXlsExporterNature)nature).getColumnAutoFit(element));
        adjustRowHeight(element.getHeight(), ((JRXlsExporterNature)nature).getRowAutoFit(element));

        short forecolor = getWorkbookColor(element.getLinePen().getLineColor()).getIndex();

        FillPatternType mode = backgroundMode;
        short backcolor = whiteIndex;
        if (!Boolean.TRUE.equals(sheetInfo.ignoreCellBackground) && element.getBackcolor() != null) {
            mode = FillPatternType.SOLID_FOREGROUND;
            backcolor = getWorkbookColor(element.getBackcolor()).getIndex();
        }

        HSSFCellStyle cellStyle =
            getLoadedCellStyle(
                mode,
                backcolor,
                HorizontalAlignment.LEFT,
                VerticalAlignment.TOP,
                (short)0,
                getLoadedFont(getDefaultFont(), forecolor, null, getLocale()),
                new BoxStyle(element),
                isCellLocked(element),
                isCellHidden(element),
                isShrinkToFit(element)
                );
        addBlankElement(cellStyle, repeatValue, currentColumnName);
    }
}
项目:jasperreports    文件:JRXlsMetadataExporter.java   
protected HSSFCellStyle getLoadedCellStyle(
    FillPatternType mode,
    short backcolor,
    HorizontalAlignment horizontalAlignment,
    VerticalAlignment verticalAlignment,
    short rotation,
    HSSFFont font,
    BoxStyle box,
    boolean isCellLocked,
    boolean isCellHidden,
    boolean isShrinkToFit
    ) 
{
    return getLoadedCellStyle(new StyleInfo(mode, backcolor, horizontalAlignment, verticalAlignment, rotation, font, box, true, isCellLocked, isCellHidden, isShrinkToFit));
}
项目:jasperreports    文件:JRXlsMetadataExporter.java   
private HorizontalAlignment getHorizontalAlignment(TextAlignHolder alignment) {
    switch (alignment.horizontalAlignment) 
    {
        case RIGHT:
            return HorizontalAlignment.RIGHT;
        case CENTER:
            return HorizontalAlignment.CENTER;
        case JUSTIFIED:
            return HorizontalAlignment.JUSTIFY;
        case LEFT:
        default:
            return HorizontalAlignment.LEFT;
    }
}
项目:jasperreports    文件:JRXlsMetadataExporter.java   
public StyleInfo(
    FillPatternType mode,
    short backcolor,
    HorizontalAlignment horizontalAlignment,
    VerticalAlignment verticalAlignment,
    short rotation,
    HSSFFont font,
    BoxStyle box,
    boolean wrapText,
    boolean cellLocked,
    boolean cellHidden,
    boolean shrinkToFit
    ) 
{
    this.mode = mode;
    this.backcolor = backcolor;
    this.horizontalAlignment = horizontalAlignment;
    this.verticalAlignment = verticalAlignment;
    this.rotation = rotation;
    this.font = font;

    this.box = box;
    this.lcWrapText = shrinkToFit ? false : wrapText;
    this.lcCellLocked = cellLocked;
    this.lcCellHidden = cellHidden;
    this.lcShrinkToFit = shrinkToFit;
    hashCode = computeHash();
}
项目:CCDA-Score-CARD    文件:ScorecardExcelGenerator.java   
public static HSSFCellStyle createCellStyleForComRepNotSetUp(HSSFWorkbook workBook) {
    HSSFCellStyle cellStyle = workBook.createCellStyle();
    HSSFFont fontObj = workBook.createFont();
    cellStyle.setAlignment(HorizontalAlignment.CENTER);
    fontObj.setFontName("Calibri");
    fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
    fontObj.setBold(true);
    fontObj.setColor((short) 10);
    cellStyle.setFont(fontObj);
    return cellStyle;
}
项目:CCDA-Score-CARD    文件:ScorecardExcelGenerator.java   
public static HSSFCellStyle createCellStyleForComRepSetUp(HSSFWorkbook workBook) {
    HSSFCellStyle cellStyle = workBook.createCellStyle();
    HSSFFont fontObj = workBook.createFont();
    cellStyle.setAlignment(HorizontalAlignment.CENTER);
    fontObj.setFontName("Calibri");
    fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
    fontObj.setBold(true);
    fontObj.setColor((short) 17);
    cellStyle.setFont(fontObj);
    return cellStyle;
}
项目:appformer    文件:DataSetExportServicesImpl.java   
private Map<String, CellStyle> createStyles(Workbook wb){
    Map<String, CellStyle> styles = new HashMap<>();
    CellStyle style;

    Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short)12);
    titleFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor( IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(titleFont);
    style.setWrapText(false);
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
    styles.put("header", style);

    Font cellFont = wb.createFont();
    cellFont.setFontHeightInPoints((short)10);
    cellFont.setBold(true);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat( BuiltinFormats.getBuiltinFormat( 3 )));
    styles.put("integer_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(4)));
    styles.put("decimal_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.LEFT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat( (short) BuiltinFormats.getBuiltinFormat("text") );
    styles.put(TEXT_CELL, style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat( DateFormatConverter.convert( Locale.getDefault(), dateFormatPattern )));
    styles.put("date_cell", style);
    return styles;
}
项目:sqlexplorer-vaadin    文件:ExcelExport.java   
public HSSFCellStyle createHeaderStyle() {
    HSSFCellStyle style = workbook.createCellStyle();
    final HSSFFont font = workbook.createFont();
    font.setBold(true);
    style.setFont(font);
    style.setBorderBottom(BorderStyle.THIN);
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setFillForegroundColor(HSSFColor.HSSFColorPredefined.PALE_BLUE.getIndex());
    return style;
}
项目:sqlexplorer-vaadin    文件:ExcelExport.java   
public HSSFCellStyle createDefaultStyle() {
    HSSFCellStyle style = workbook.createCellStyle();
    HSSFFont font = workbook.createFont();
    style.setFont(font);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setAlignment(HorizontalAlignment.CENTER);
    return style;
}
项目:dashbuilder    文件:DataSetExportServicesImpl.java   
private Map<String, CellStyle> createStyles(Workbook wb){
    Map<String, CellStyle> styles = new HashMap<>();
    CellStyle style;

    Font titleFont = wb.createFont();
    titleFont.setFontHeightInPoints((short)12);
    titleFont.setBold(true);
    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.CENTER);
    style.setFillForegroundColor( IndexedColors.GREY_25_PERCENT.getIndex());
    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    style.setFont(titleFont);
    style.setWrapText(false);
    style.setBorderBottom(BorderStyle.THIN);
    style.setBottomBorderColor(IndexedColors.GREY_80_PERCENT.getIndex());
    styles.put("header", style);

    Font cellFont = wb.createFont();
    cellFont.setFontHeightInPoints((short)10);
    cellFont.setBold(true);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat( BuiltinFormats.getBuiltinFormat( 3 )));
    styles.put("integer_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.RIGHT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(4)));
    styles.put("decimal_number_cell", style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.LEFT);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat( (short) BuiltinFormats.getBuiltinFormat("text") );
    styles.put(TEXT_CELL, style);

    style = wb.createCellStyle();
    style.setAlignment(HorizontalAlignment.CENTER);
    style.setVerticalAlignment(VerticalAlignment.BOTTOM);
    style.setFont(cellFont);
    style.setWrapText(false);
    style.setDataFormat(wb.createDataFormat().getFormat( DateFormatConverter.convert( Locale.getDefault(), dateFormatPattern )));
    styles.put("date_cell", style);
    return styles;
}
项目:ph-poi    文件:ExcelStyleTest.java   
@Test
public void testAlign ()
{
  final ExcelStyle e = new ExcelStyle ();
  assertNull (e.getAlign ());
  CommonsTestHelper.testGetClone (e);
  for (final HorizontalAlignment eAlign : HorizontalAlignment.values ())
  {
    assertSame (e, e.setAlign (eAlign));
    assertEquals (eAlign, e.getAlign ());
    CommonsTestHelper.testGetClone (e);
  }
}
项目:metamodel    文件:ExcelInsertBuilder.java   
private HorizontalAlignment getAlignment(TextAlignment alignment) {
    switch (alignment) {
    case LEFT:
        return HorizontalAlignment.LEFT;
    case RIGHT:
        return HorizontalAlignment.RIGHT;
    case CENTER:
        return HorizontalAlignment.CENTER;
    case JUSTIFY:
        return HorizontalAlignment.JUSTIFY;
    default:
        throw new IllegalArgumentException("Unknown alignment type: "
                + alignment);
    }
}
项目:vaadin-gridexport    文件:ExcelExport.java   
protected void setupCell(Cell sheetCell, Object value, Class<?> valueType, String propId, Object rootItemId, int row, int col) {
    sheetCell.setCellStyle(getCellStyle(propId, rootItemId, row, col, false));
    final HorizontalAlignment poiAlignment = getGridHolder().getCellAlignment(propId);
    CellUtil.setAlignment(sheetCell, poiAlignment);
    setCellValue(sheetCell, value, valueType, propId);
}
项目:bdf2    文件:GridStyleBuilder.java   
private Map<String, CellStyle> createHSSFCellStyles(Workbook wb, int[] contextBgColor, int[] contextFontColor, int contextFontSize, int contextFontAlign, int[] headerBgColor,
        int[] headerFontColor, int headerFontSize, int headerAlign) {
    Map<String, CellStyle> styles = new HashMap<String, CellStyle>();

    HSSFWorkbook workbook = (HSSFWorkbook) wb;
    HSSFPalette palette = workbook.getCustomPalette();
    palette.setColorAtIndex((short) 11, (byte) contextBgColor[0], (byte) contextBgColor[1], (byte) contextBgColor[2]);
    palette.setColorAtIndex((short) 12, (byte) contextFontColor[0], (byte) contextFontColor[1], (byte) contextFontColor[2]);
    palette.setColorAtIndex((short) 13, (byte) headerBgColor[0], (byte) headerBgColor[1], (byte) headerBgColor[2]);
    palette.setColorAtIndex((short) 14, (byte) headerFontColor[0], (byte) headerFontColor[1], (byte) headerFontColor[2]);

    HSSFFont headerFont = workbook.createFont();
    headerFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
    headerFont.setFontName("宋体");
    headerFont.setColor((short) 14);
    headerFont.setBold(true);
    headerFont.setFontHeightInPoints((short) headerFontSize);
    CellStyle headerStyle = this.createBorderCellStyle(workbook, true);

    headerStyle.setFont(headerFont);
    headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    headerStyle.setFillForegroundColor((short) 13);
    this.setCellStyleAligment(headerStyle, headerAlign);
    headerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    styles.put(GridStyleType.headerStyle.name(), headerStyle);

    HSSFFont dataFont = workbook.createFont();
    dataFont.setColor((short) 12);
    dataFont.setFontHeightInPoints((short) contextFontSize);
    dataFont.setCharSet(HSSFFont.DEFAULT_CHARSET);
    dataFont.setFontName("宋体");

    CellStyle dataAlignLeftStyle = this.createBorderCellStyle(workbook, true);
    dataAlignLeftStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    dataAlignLeftStyle.setFillForegroundColor((short) 11);
    dataAlignLeftStyle.setFont(dataFont);
    dataAlignLeftStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    dataAlignLeftStyle.setWrapText(true);
    dataAlignLeftStyle.setAlignment(HorizontalAlignment.LEFT);
    styles.put(GridStyleType.dataAlignLeftStyle.name(), dataAlignLeftStyle);

    CellStyle dataAlignCenterStyle = this.createBorderCellStyle(workbook, true);
    dataAlignCenterStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    dataAlignCenterStyle.setFillForegroundColor((short) 11);
    dataAlignCenterStyle.setFont(dataFont);
    dataAlignCenterStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    dataAlignCenterStyle.setWrapText(true);
    dataAlignCenterStyle.setAlignment(HorizontalAlignment.CENTER);
    styles.put(GridStyleType.dataAlignCenterStyle.name(), dataAlignCenterStyle);

    CellStyle dataAlignRightStyle = this.createBorderCellStyle(workbook, true);
    dataAlignRightStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    dataAlignRightStyle.setFillForegroundColor((short) 11);
    dataAlignRightStyle.setFont(dataFont);
    dataAlignRightStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    dataAlignRightStyle.setWrapText(true);
    dataAlignRightStyle.setAlignment(HorizontalAlignment.RIGHT);
    styles.put(GridStyleType.dataAlignRightStyle.name(), dataAlignRightStyle);

    CellStyle dateStyle = this.createBorderCellStyle(workbook, true);
    CreationHelper helper = workbook.getCreationHelper();
    dateStyle.setDataFormat(helper.createDataFormat().getFormat("m/d/yy h:mm"));
    dateStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
    dateStyle.setFillForegroundColor((short) 11);
    dateStyle.setFont(dataFont);
    dateStyle.setVerticalAlignment(VerticalAlignment.CENTER);
    this.setCellStyleAligment(dateStyle, contextFontAlign);
    styles.put(GridStyleType.dateStyle.name(), dateStyle);

    return styles;
}