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


Java CellUtil类代码示例

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


CellUtil类属于org.apache.poi.ss.util包,在下文中一共展示了CellUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createWageringHeaderRow

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
public static XSSFRow createWageringHeaderRow(XSSFSheet sheet, int row, int col) {
    XSSFRow headerRow = sheet.createRow(row++);

    col = seedCols(col, headerRow);

    List<String> columns = Arrays.asList("winPayoff", "placePayoff",
            "showPayoff", "totalWpsPool", "doublePayoff", "doublePool", "exactaPayoff",
            "exactaPool", "trifectaPayoff", "trifectaPool", "superfectaPayoff",
            "superfectaPool", "pick3Payoff", "pick3Pool", "pick4Payoff", "pick4Pool",
            "pick5Payoff", "pick5Pool");
    for (String column : columns) {
        CellUtil.createCell(headerRow, col++, column);
    }

    return headerRow;
}
 
开发者ID:robinhowlett,项目名称:handycapper,代码行数:17,代码来源:ThreeTypeSummary.java

示例4: test2

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
@Test
public void test2() throws IOException{
	 Workbook wb = new HSSFWorkbook();
	    Sheet sheet = wb.createSheet("new sheet");

	    // Create a row and put some cells in it. Rows are 0 based.
	    Row row = sheet.createRow(1);

	    // Create a cell and put a value in it.
	    

	    // Style the cell with borders all around.
	    CellStyle style = wb.createCellStyle();
	    
	    //     style.setFillBackgroundColor(IndexedColors.AUTOMATIC.getIndex());
	   style.setFillPattern(CellStyle.SOLID_FOREGROUND);
	   style.setFillForegroundColor(IndexedColors.LIGHT_ORANGE.index);
	   
	    Font font = wb.createFont();
	    font.setFontHeightInPoints((short)24);
	    font.setFontName("Courier New");
	    font.setItalic(true);
	    font.setStrikeout(true);
	    style.setFont(font);
	    CellUtil.createCell(row, 1, "nihao",style);
	    //style.setFont(font);
	    // Write the output to a file
	    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
	    wb.write(fileOut);
	    fileOut.close();
}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:32,代码来源:MyTest.java

示例5: getCell

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
protected Cell getCell(Column column) {
	Cell cell = CellUtil.getCell(getRow(), column.getIndex());

	ColumnOption option = getColumnOption(column);
	if (option != null) {
		Optional<String> formatOption = option.getDataFormat();
		if (formatOption.isPresent()) {
			String formatString = formatOption.get();
			CellStyle style = styleMap.get(formatString);
			if (style == null) {
				Workbook book = sheet.getWorkbook();
				style = book.createCellStyle();
				CreationHelper helper = book.getCreationHelper();
				short fmt = helper.createDataFormat().getFormat(formatString);
				style.setDataFormat(fmt);
				styleMap.put(formatString, style);
			}
			cell.setCellStyle(style);
		}
	}

	return cell;
}
 
开发者ID:hishidama,项目名称:embulk-formatter-poi_excel,代码行数:24,代码来源:PoiExcelColumnVisitor.java

示例6: 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

示例7: setBorder

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
public void setBorder(JTable currentTable, short thickness, short color) {
    SheetTableModel tableModel = (SheetTableModel) currentTable.getModel();
    List<Cell> selectedCells = CellUtils.getSelectedCells(currentTable, true);
    for (Cell cell : selectedCells) {
        Workbook workbook = cell.getSheet().getWorkbook();
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.BORDER_TOP, thickness);
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.TOP_BORDER_COLOR, color);
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.BORDER_LEFT, thickness);
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.LEFT_BORDER_COLOR, color);
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.BORDER_BOTTOM, thickness);
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.BOTTOM_BORDER_COLOR, color);
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.BORDER_RIGHT, thickness);
        CellUtil.setCellStyleProperty(cell, workbook, CellUtil.RIGHT_BORDER_COLOR, color);
        tableModel.fireTableCellUpdated(cell.getRowIndex(), cell.getColumnIndex());
    }
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:17,代码来源:SetBordersAction.java

示例8: createBreedingHeaderRow

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
public static XSSFRow createBreedingHeaderRow(XSSFSheet sheet, int row, int col) {
    XSSFRow headerRow = sheet.createRow(row++);

    col = standardCols(col, headerRow);

    List<String> columns = Arrays.asList("sex", "sire", "dam", "damSire", "foalDate", "age");
    for (String column : columns) {
        CellUtil.createCell(headerRow, col++, column);
    }

    return headerRow;
}
 
开发者ID:robinhowlett,项目名称:handycapper,代码行数:13,代码来源:ThreeTypeSummary.java

示例9: seedCols

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
static int seedCols(int col, XSSFRow headerRow) {
    List<String> columns = Arrays.asList("date", "track", "raceNumber", "type", "raceName",
            "grade", "purse", "dist f", "dist", "surface");
    for (String column : columns) {
        CellUtil.createCell(headerRow, col++, column);
    }
    return col;
}
 
开发者ID:robinhowlett,项目名称:handycapper,代码行数:9,代码来源:ThreeTypeSummary.java

示例10: standardCols

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
static int standardCols(int col, XSSFRow headerRow) {
    col = seedCols(col, headerRow);
    List<String> columns = Arrays.asList("name", "pp", "odds", "favorite", "choice",
            "position", "trainer", "jockey", "final time", "seconds");
    for (String column : columns) {
        CellUtil.createCell(headerRow, col++, column);
    }
    return col;
}
 
开发者ID:robinhowlett,项目名称:handycapper,代码行数:10,代码来源:ThreeTypeSummary.java

示例11: setFormRegionStyle

import org.apache.poi.ss.util.CellUtil; //导入依赖的package包/类
private void setFormRegionStyle(Sheet sheet, CellRangeAddress ca, CellStyle cs) {
	for (int i = ca.getFirstRow(); i <= ca.getLastRow(); i++) {
		Row row = CellUtil.getRow(i, sheet);
		for (int j = ca.getFirstColumn(); j <= ca.getLastColumn(); j++) {
			Cell cell = CellUtil.getCell(row, j);
			cell.setCellStyle(cs);
		}
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:10,代码来源:ExcelReportBuilder.java

示例12: 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

示例13: 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

示例14: 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

示例15: 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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。