当前位置: 首页>>代码示例>>Java>>正文


Java CellUtil.setAlignment方法代码示例

本文整理汇总了Java中org.apache.poi.ss.util.CellUtil.setAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java CellUtil.setAlignment方法的具体用法?Java CellUtil.setAlignment怎么用?Java CellUtil.setAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.ss.util.CellUtil的用法示例。


在下文中一共展示了CellUtil.setAlignment方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupTotalCell

import org.apache.poi.ss.util.CellUtil; //导入方法依赖的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

示例2: addHeaderRow

import org.apache.poi.ss.util.CellUtil; //导入方法依赖的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

示例3: createTableHeader

import org.apache.poi.ss.util.CellUtil; //导入方法依赖的package包/类
private Cell createTableHeader(HSSFSheet sheet, int col, String label) {

		int n = sheet.getPhysicalNumberOfRows();
		Row row = null;

		if (n < 1)
			row = sheet.createRow(0);
		else
			row = sheet.getRow(0);

		Cell cell = row.createCell(col);
		cell.setCellValue(label);
		cell.setCellStyle(boldStyle);
		CellUtil.setAlignment(cell, sheet.getWorkbook(), CellStyle.ALIGN_CENTER);

		return cell;

	}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:19,代码来源:ExportExcel.java

示例4: addTableCell

import org.apache.poi.ss.util.CellUtil; //导入方法依赖的package包/类
private Cell addTableCell(Row row, int col, String label) {
	Cell cell = row.createCell(col);
	cell.setCellValue(label);
	CellUtil.setAlignment(cell, row.getSheet().getWorkbook(),
			CellStyle.ALIGN_LEFT);

	return cell;
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:9,代码来源:ExportExcel.java

示例5: createInputCell

import org.apache.poi.ss.util.CellUtil; //导入方法依赖的package包/类
private Cell createInputCell(Sheet sheet, String label) {
	Row row = sheet.createRow(sheet.getPhysicalNumberOfRows());
	Cell cell1 = row.createCell(0);
	cell1.setCellValue(label + ":");
	Cell cell2 = row.createCell(1);
	CellUtil.setAlignment(cell2, sheet.getWorkbook(), CellStyle.ALIGN_RIGHT);

	inputCells.put(label, cell2);

	return cell2;
}
 
开发者ID:dawg6,项目名称:dhcalc,代码行数:12,代码来源:ExportExcel.java

示例6: setupCell

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

示例7: addDataRow

import org.apache.poi.ss.util.CellUtil; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void addDataRow(final Sheet sheetToAddTo, final Object rootItemId, final int row) {
    final Row sheetRow = sheetToAddTo.createRow(row);
    Property prop;
    Object propId;
    Object value;
    Cell sheetCell;
    for (int col = 0; col < getPropIds().size(); col++) {
        propId = getPropIds().get(col);
        prop = getProperty(rootItemId, propId);
        if (null == prop) {
            value = null;
        } else {
            value = prop.getValue();
        }
        sheetCell = sheetRow.createCell(col);
        final CellStyle cs = getCellStyle(rootItemId, row, col, false);
        sheetCell.setCellStyle(cs);
        final Short poiAlignment = getTableHolder().getCellAlignment(propId);
        CellUtil.setAlignment(sheetCell, workbook, poiAlignment);
        if (null != value) {
            if (!isNumeric(prop.getType())) {
                if (Date.class.isAssignableFrom(prop.getType())) {
                    sheetCell.setCellValue((Date) value);
                } else if (LocalDate.class.isAssignableFrom(prop.getType())) {
                    sheetCell.setCellValue(((LocalDate) value).toDate());
                } else if (DateTime.class.isAssignableFrom(prop.getType())) {
                    sheetCell.setCellValue(((DateTime) value).toGregorianCalendar());
                } else {
                    sheetCell.setCellValue(createHelper.createRichTextString(value.toString()));
                }
            } else {
                try {
                    // parse all numbers as double, the format will determine how they appear
                    final Double d = Double.parseDouble(value.toString());
                    sheetCell.setCellValue(d);
                } catch (final NumberFormatException nfe) {
                    sheetCell.setCellValue(createHelper.createRichTextString(value.toString()));
                }
            }
        }
    }
}
 
开发者ID:ExtaSoft,项目名称:extacrm,代码行数:45,代码来源:MyExcelExport.java


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