本文整理匯總了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);
}
示例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);
}
}
}
}
}
示例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);
}