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


Java Cell.getRowIndex方法代码示例

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


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

示例1: formatCellStatus

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
protected void formatCellStatus(Sheet sheet, Cell cell) {
	cell.setCellStyle(styles.get("status"));
	SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
	ConditionalFormattingRule ruleGreen = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "1");
	PatternFormatting fill1 = ruleGreen.createPatternFormatting();
	fill1.setFillBackgroundColor(IndexedColors.GREEN.index);
	fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleRed = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "0");
	PatternFormatting fill2 = ruleRed.createPatternFormatting();
	fill2.setFillBackgroundColor(IndexedColors.RED.index);
	fill2.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	ConditionalFormattingRule ruleOrange = sheetCF.createConditionalFormattingRule(ComparisonOperator.EQUAL, "2");
	PatternFormatting fill3 = ruleOrange.createPatternFormatting();
	fill3.setFillBackgroundColor(IndexedColors.ORANGE.index);
	fill3.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
	//
	String name = CellReference.convertNumToColString(cell.getColumnIndex());
	String location = "$" + name + "$" + cell.getRowIndex() + ":$" + name + "$" + (cell.getRowIndex() + 1);

	CellRangeAddress[] regions = { CellRangeAddress.valueOf(location) };
	ConditionalFormattingRule[] cfRules = new ConditionalFormattingRule[] { ruleGreen, ruleRed, ruleOrange };
	sheetCF.addConditionalFormatting(regions, cfRules);
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:XLTest.java

示例2: loadDataBlock

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
/**
 * Parses the test case data (the data between TEST_CASE_START and TEST_CASE_END commented cells) from the
 * excel spreadsheet and loads it into a two-dimensional Object[][] array - workingObjectArray
 */
private void loadDataBlock(
                            Method method ) throws DataProviderException {

    Sheet sheet = excelFileWorkbook.getSheet(this.sheetName);
    if (sheet == null) {
        throw new DataProviderException(UNABLE_TO_LOAD_SHEETS + this.sheetName);
    }

    //Get the starting cell coordinates
    Cell startingCell = getStartingCell(sheet);
    int startCol = startingCell.getColumnIndex();
    int startRow = startingCell.getRowIndex();

    //Get the ending cell coordinates
    Cell endingCell = getEndingCell(sheet);
    int endCol = endingCell.getColumnIndex();
    int endRow = endingCell.getRowIndex();

    if (method.getParameterTypes().length != (endCol - startCol) + 1) {
        throw new DataProviderException(" Expected " + method.getParameterTypes().length
                                        + " parameters in the test method while the table has "
                                        + ( (endCol - startCol) + 1));
    }
    // If the data table is to be returned as a Cartesian product of the rows (the not empty cells)
    if (isMultipliable) {
        makeCartesianProductTable(startCol, startRow, endCol, endRow, sheet, method);
    } else {
        // Initialize the object array
        int columns = endCol - startCol + 1;
        int rows = endRow - startRow + 1;
        this.log.debug(CREATING_DATA_BLOCK + columns + "/" + rows);
        this.workingObjectArray = new Object[rows][columns];

        //Fill the object array iterating the sheet column by column
        for (int col = startCol, parameterIndex = 0; col <= endCol; col++, parameterIndex++) {

            //Get the type of the method parameter at the current position
            Class<?> parameterType = getParameterTypeAt(method, parameterIndex);

            //Iterate over the current column to load the cells according to the parameter type
            for (int row = startRow; row <= endRow; row++) {
                Row rowValue = sheet.getRow(row);
                if (rowValue != null) {
                    Cell currentCell = rowValue.getCell(col, Row.CREATE_NULL_AS_BLANK);
                    this.workingObjectArray[row - startRow][parameterIndex] = parseCellContents(currentCell,
                                                                                                parameterType);
                }
            }
        }
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:56,代码来源:ExcelParser.java

示例3: writeCell

import org.apache.poi.ss.usermodel.Cell; //导入方法依赖的package包/类
/**
 * Writes out an XML cell based on an Excel cell's actual value
 * 
 * @param cell
 *            The Excel cell
 * @param out
 *            the output stream
 * @param columns
 *            the Map with column titles
 */
private void writeCell(final Cell cell, final XMLStreamWriter out, final Map<String, String> columns) {

	String cellValue = this.getCellValue(cell);
	int col = cell.getColumnIndex();
	int row = cell.getRowIndex();
	this.writeAnyCell(row, col, cellValue, out, columns);
}
 
开发者ID:Stwissel,项目名称:Excel2XML,代码行数:18,代码来源:E2xCmdline.java


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