本文整理了Java中org.apache.poi.ss.usermodel.Row.getRowNum
方法的一些代码示例,展示了Row.getRowNum
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Row.getRowNum
方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Row
类名称:Row
方法名:getRowNum
[英]Get row number this row represents
[中]获取此行代表的行号
代码示例来源:origin: pentaho/pentaho-kettle
public int getRow() {
Row row = cell.getRow();
return row.getRowNum();
}
}
代码示例来源:origin: kiegroup/optaplanner
protected long readLongCell(Cell cell) {
double d = cell.getNumericCellValue();
long l = (long) d;
if (d - (double) l != 0.0) {
throw new IllegalArgumentException("The keyCell (" + cell.getRow().getRowNum() + ","
+ cell.getColumnIndex() + ") with value (" + d + ") is expected to be a long.");
}
return l;
}
代码示例来源:origin: kiegroup/optaplanner
protected double readDoubleParameter(Row row, String key) {
Cell keyCell = row.getCell(0);
if (!key.equals(keyCell.getStringCellValue())) {
throw new IllegalArgumentException("The keyCell (" + keyCell.getRow().getRowNum() + ","
+ keyCell.getColumnIndex() + ") with value (" + keyCell.getStringCellValue()
+ ") is expected to have the key (" + key + ")");
}
Cell valueCell = row.getCell(1);
return valueCell.getNumericCellValue();
}
}
代码示例来源:origin: kiegroup/optaplanner
protected String readStringParameter(Row row, String key) {
Cell keyCell = row.getCell(0);
if (!key.equals(keyCell.getStringCellValue())) {
throw new IllegalArgumentException("The keyCell (" + keyCell.getRow().getRowNum() + ","
+ keyCell.getColumnIndex() + ") with value (" + keyCell.getStringCellValue()
+ ") is expected to have the key (" + key + ")");
}
Cell valueCell = row.getCell(1);
return valueCell.getStringCellValue();
}
代码示例来源:origin: kiegroup/optaplanner
protected void assertCellConstant(Cell cell, String constant) {
if (!constant.equals(cell.getStringCellValue())) {
throw new IllegalArgumentException("The cell (" + cell.getRow().getRowNum() + ","
+ cell.getColumnIndex() + ") with value (" + cell.getStringCellValue()
+ ") is expected to have the constant (" + constant + ")");
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
final int rowNum = row.getRowNum();
final Integer rowNumI = Integer.valueOf(rowNum); // NOSONAR
代码示例来源:origin: kiegroup/optaplanner
private void readRegionList() throws IOException {
Sheet sheet = readSheet(1, "Regions");
Row headerRow = sheet.getRow(0);
assertCellConstant(headerRow.getCell(0), "Name");
assertCellConstant(headerRow.getCell(1), "Quantity maximum");
List<Region> regionList = new ArrayList<>();
regionMap = new LinkedHashMap<>();
long id = 0L;
for (Row row : sheet) {
if (row.getRowNum() < 1) {
continue;
}
if (row.getCell(0) == null && row.getCell(1) == null) {
continue;
}
Region region = new Region();
region.setId(id);
id++;
region.setName(readStringCell(row.getCell(0)));
region.setQuantityMillisMaximum(parsePercentageMillis(readDoubleCell(row.getCell(1))));
regionList.add(region);
regionMap.put(region.getName(), region);
}
solution.setRegionList(regionList);
}
代码示例来源:origin: kiegroup/optaplanner
private void readSectorList() throws IOException {
Sheet sheet = readSheet(2, "Sectors");
Row headerRow = sheet.getRow(0);
assertCellConstant(headerRow.getCell(0), "Name");
assertCellConstant(headerRow.getCell(1), "Quantity maximum");
List<Sector> sectorList = new ArrayList<>();
sectorMap = new LinkedHashMap<>();
long id = 0L;
for (Row row : sheet) {
if (row.getRowNum() < 1) {
continue;
}
if (row.getCell(0) == null && row.getCell(1) == null) {
continue;
}
Sector sector = new Sector();
sector.setId(id);
id++;
sector.setName(readStringCell(row.getCell(0)));
sector.setQuantityMillisMaximum(parsePercentageMillis(readDoubleCell(row.getCell(1))));
sectorList.add(sector);
sectorMap.put(sector.getName(), sector);
}
solution.setSectorList(sectorList);
}
代码示例来源:origin: kiegroup/optaplanner
if (row.getRowNum() < 2) {
continue;
throw new IllegalArgumentException("The row (" + row.getRowNum() + ") has "
+ row.getPhysicalNumberOfCells() + " cells, but is expected to have "
+ (ASSET_CLASS_PROPERTIES_COUNT + assetClassListSize) + " cells instead.");
AssetClass assetClass = idToAssetClassMap.get(id);
if (assetClass == null) {
throw new IllegalStateException("The row (" + row.getRowNum()
+ ") has an assetClass id (" + id + ") that is not in the header.");
Region region = regionMap.get(regionName);
if (region == null) {
throw new IllegalStateException("The row (" + row.getRowNum()
+ ") has a region (" + regionName + ") that is not in the regions sheet.");
Sector sector = sectorMap.get(sectorName);
if (sector == null) {
throw new IllegalStateException("The row (" + row.getRowNum()
+ ") has a sector (" + sectorName + ") that is not in the sectors sheet.");
代码示例来源:origin: org.apache.poi/poi
HSSFCell xcell = (HSSFCell) cell;
if (xcell.isPartOfArrayFormulaGroup()) {
String msg = "Row[rownum=" + row.getRowNum() + "] contains cell(s) included in a multi-cell array formula. You cannot change part of an array.";
xcell.notifyArrayFormulaChanging(msg);
Integer key = Integer.valueOf(row.getRowNum());
HSSFRow removedRow = _rows.remove(key);
if (removedRow != row) {
代码示例来源:origin: org.apache.poi/poi-ooxml
_cellCache = new HashMap<>(_xs.getLastRowNum() * 3);
for (final Row row : _xs) {
final int rowNum = row.getRowNum();
for (final Cell cell : row) {
代码示例来源:origin: org.apache.poi/poi-ooxml
/**
* Shift a formula using the supplied FormulaShifter
*
* @param row the row of the cell this formula belongs to. Used to get a reference to the parent workbook.
* @param formula the formula to shift
* @param formulaShifter the FormulaShifter object that operates on the parsed formula tokens
* @return the shifted formula if the formula was changed,
* <code>null</code> if the formula wasn't modified
*/
/*package*/
static String shiftFormula(Row row, String formula, FormulaShifter formulaShifter) {
Sheet sheet = row.getSheet();
Workbook wb = sheet.getWorkbook();
int sheetIndex = wb.getSheetIndex(sheet);
final int rowIndex = row.getRowNum();
XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create((XSSFWorkbook) wb);
try {
Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.CELL, sheetIndex, rowIndex);
String shiftedFmla = null;
if (formulaShifter.adjustFormula(ptgs, sheetIndex)) {
shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
}
return shiftedFmla;
} catch (FormulaParseException fpe) {
// Log, but don't change, rather than breaking
logger.log(POILogger.WARN, "Error shifting formula on row ", row.getRowNum(), fpe);
return formula;
}
}
代码示例来源:origin: org.apache.poi/poi-ooxml
final int srcStartRowNum = srcStartRow.getRowNum();
final int srcEndRowNum = srcEndRow.getRowNum();
destRowNum = r++;
} else {
final int shift = (srcRow.getRowNum() - srcStartRowNum);
destRowNum = destStartRow + shift;
代码示例来源:origin: org.apache.poi/poi
if (region.isInRange(row.getRowNum(), column)) {
if (!useMergedCells) {
代码示例来源:origin: stackoverflow.com
@Override
public void import(FileBean fileBean) {
ByteArrayInputStream bis = new ByteArrayInputStream(filedBean.getFileData().getBytes());
Workbook workbook;
try {
if (fileBean.getFileData().getOriginalFilename().endsWith("xls")) {
workbook = new HSSFWorkbook(bis);
} else if (fileBean.getFileData().getOriginalFilename().endsWith("xlsx")) {
workbook = new XSSFWorkbook(bis);
} else {
throw new IllegalArgumentException("Received file does not have a standard excel extension.");
}
for (Row row : sheet) {
if (row.getRowNum() == 0) {
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
//go from cell to cell and do create sql based on the content
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
File file = new File("D:/temp/test.xlsx");
FileInputStream fis = new FileInputStream(file);
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sh = wb.getSheet("Hola");
System.out.println(sh.getLastRowNum());
System.out.println("Name: "+sh.getSheetName());
Row row = sh.getRow(1);
System.out.println(row.getRowNum());
System.out.println("Val: "+sh.getRow(1).getCell(1).getStringCellValue());
代码示例来源:origin: stackoverflow.com
private static int findRow(HSSFSheet sheet, String cellContent) {
for (Row row : sheet) {
for (Cell cell : row) {
if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
if (cell.getRichStringCellValue().getString().trim().equals(cellContent)) {
return row.getRowNum();
}
}
}
}
return 0;
}
代码示例来源:origin: org.apache.poi/poi-ooxml
final int srcRowNum = srcRow.getRowNum();
final int destRowNum = getRowNum();
final int rowDifference = destRowNum - srcRowNum;
代码示例来源:origin: net.sf.jxls/jxls-core
public void removeRowCells(Row row, int startCellNum, int endCellNum) {
transformations.add( new RemoveTransformation( new Block(sheet, row.getRowNum(), startCellNum, row.getRowNum(), endCellNum)) );
ShiftTransformation shiftTransformation = new ShiftTransformation(new Block(sheet, row.getRowNum(), (int) (endCellNum + 1), row.getRowNum(), Integer.MAX_VALUE), 0, endCellNum - startCellNum + 1);
transformations.add( shiftTransformation );
transformations.add( new RemoveTransformation( new Block(sheet, row.getRowNum(), (int) (row.getLastCellNum() - (endCellNum - startCellNum)), row.getRowNum(), row.getLastCellNum())));
formulaController.updateWorkbookFormulas( shiftTransformation );
TagBodyHelper.removeRowCells( sheet.getPoiSheet(), row, startCellNum, endCellNum );
}
代码示例来源:origin: net.sf.jxls/jxls-core
private static void removeMergedRegions(Sheet sheet, Row row) {
if (row != null && row.getFirstCellNum() >= 0 && row.getLastCellNum() >= 0) {
int i = row.getRowNum();
for (int j = row.getFirstCellNum(), c = row.getLastCellNum(); j <= c; j++) {
Util.removeMergedRegion(sheet, i, j);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!