• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HorizontalAlignment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.poi.ss.usermodel.HorizontalAlignment的典型用法代码示例。如果您正苦于以下问题:Java HorizontalAlignment类的具体用法?Java HorizontalAlignment怎么用?Java HorizontalAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HorizontalAlignment类属于org.apache.poi.ss.usermodel包,在下文中一共展示了HorizontalAlignment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createIndentationCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:14,代码来源:GridStyleBuilder.java


示例2: defaultDataCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:25,代码来源:ExcelExport.java


示例3: setupTotalCell

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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"));
        }
    }
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:23,代码来源:ExcelExport.java


示例4: defaultHeaderCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:23,代码来源:ExcelExport.java


示例5: defaultTitleCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:20,代码来源:ExcelExport.java


示例6: createHSSFCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:24,代码来源:TitleStyleBuilder.java


示例7: addHeaderRow

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 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++;
    }
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:24,代码来源:ExcelExport.java


示例8: getLoadedCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:18,代码来源:JRXlsExporter.java


示例9: StyleInfo

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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);
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:27,代码来源:JRXlsExporter.java


示例10: writeCondtions

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 表头条件
 * @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();
	}
}
 
开发者ID:leiyong0326,项目名称:phone,代码行数:25,代码来源:ExcelExportSuper.java


示例11: createCellStyleForColumnHeading

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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;
}
 
开发者ID:siteadmin,项目名称:CCDA-Score-CARD,代码行数:21,代码来源:ScorecardExcelGenerator.java


示例12: hAlignToPoi

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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();
    }
}
 
开发者ID:xzel23,项目名称:meja,代码行数:17,代码来源:PoiHelper.java


示例13: poiToHAlign

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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;
    }
}
 
开发者ID:xzel23,项目名称:meja,代码行数:17,代码来源:PoiHelper.java


示例14: createSheetRow

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:AlfrescoBenchmark,项目名称:alfresco-benchmark,代码行数:51,代码来源:XLSXReporter.java


示例15: getCellAlignment

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
@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;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:11,代码来源:DefaultGridHolder.java


示例16: defaultTotalsDoubleCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:19,代码来源:ExcelExport.java


示例17: defaultTotalsIntegerCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:TFyre,项目名称:vaadin-gridexport,代码行数:19,代码来源:ExcelExport.java


示例18: setCellStyleAligment

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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);
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:10,代码来源:AbstractStyleBuilder.java


示例19: createXSSFCellStyle

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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;
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:25,代码来源:TitleStyleBuilder.java


示例20: createAlign

import org.apache.poi.ss.usermodel.HorizontalAlignment; //导入依赖的package包/类
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;
}
 
开发者ID:bingoohuang,项目名称:excel2javabeans,代码行数:16,代码来源:ExcelBeanFieldParser.java



注:本文中的org.apache.poi.ss.usermodel.HorizontalAlignment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultConfiguration类代码示例发布时间:2022-05-21
下一篇:
Java Vector2D类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap