org.apache.poi.ss.usermodel.Row.cellIterator()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.apache.poi.ss.usermodel.Row.cellIterator方法的一些代码示例,展示了Row.cellIterator的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Row.cellIterator方法的具体详情如下:
包路径:org.apache.poi.ss.usermodel.Row
类名称:Row
方法名:cellIterator

Row.cellIterator介绍

暂无

代码示例

代码示例来源:origin: org.apache.poi/poi-ooxml

for(Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
  Cell cell = ri.next();

代码示例来源: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

Iterator<Cell> cellIterator = row.cellIterator();

代码示例来源:origin: mrdear/JavaWEB

Iterator<Cell> firstCell = firstRow.cellIterator();
  lineNumber++;
  Map<String, Object> tempMap = new HashMap<>();
  Iterator<Cell> cellIterator = x.cellIterator();
  cellIterator.forEachRemaining(y -> {
   Object value = null;

代码示例来源:origin: stackoverflow.com

for (; rowIterator.hasNext(); cellIterator.hasNext())
{
 Row row = (Row)rowIterator.next();
 cellIterator = row.cellIterator();
 continue;
 Cell cell = (Cell)cellIterator.next();

代码示例来源:origin: stackoverflow.com

Row row = sheet.getRow(rowIndex); //rowIndex is the row number you want to read from
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
  //your code
}

代码示例来源:origin: stackoverflow.com

Iterator<Row> it = XXXPresentSheet.iterator();  
while(it.hasNext()) { 
  int column = 0;
  Row row = it.next();                
  Iterator<Cell> cellIter = row.cellIterator();
  while(cellIter.hasNext()) {
    column++;
    String field1 = cellIter.next().getStringCellValue();                
    if(field1 == "XXX") {
      System.out.println(column);
    }
  }
}

代码示例来源:origin: stackoverflow.com

Iterator<Row> rowIterator = sheet.iterator();

 while (rowIterator.hasNext()) {
  Row row = rowIterator.next();

  Iterator<Cell> cellIterator = row.cellIterator();
  while (cellIterator.hasNext()) {
    Cell cell = cellIterator.next();
      cell.getStringCellValue(); //Do something useful with me
...

代码示例来源:origin: stackoverflow.com

while(rowIterator.hasNext()) {
  Row row = rowIterator.next();
  String RowContent = null;
  Iterator<Cell> cellIterator = row.cellIterator();
  while(cellIterator.hasNext()) {
    Cell cell = cellIterator.next();
    RowContent=RowContent+cell.toString();
  }
  //Code for saving RowContent or printing or whatever you want for text in complete row
}

代码示例来源:origin: eBay/xcelite

private boolean isBlankRow(Row row) {
 Iterator<Cell> cellIterator = row.cellIterator();
 boolean blankRow = true;
 while (cellIterator.hasNext()) {  
  Object value = readValueFromCell(cellIterator.next());
  if (blankRow && value != null && !String.valueOf(value).isEmpty()) {
   blankRow = false;
  }
 }
 return blankRow;
}

代码示例来源:origin: net.paissad.tools.reqcoco.parser/reqcoco-parser-xlsx

private Map<String, Integer> getCellHeadersPositions(final Row row) {
  final Map<String, Integer> headers = new HashMap<>();
  final Iterator<Cell> cellIterator = row.cellIterator();
  while (cellIterator.hasNext()) {
    final Cell cell = cellIterator.next();
    final String name = cell.getStringCellValue();
    final Integer position = cell.getColumnIndex();
    headers.put(name.toLowerCase(Locale.US), position);
  }
  return headers;
}

代码示例来源:origin: gradle.plugin.net.mbonnin/strings2xls

private void parse(HSSFSheet sheet) throws IOException, TransformerException {
  Row row = sheet.getRow(0);
  Iterator<Cell> cells = row.cellIterator();
  cells.next();// ignore key
  int i = 1;
  while (cells.hasNext()) {
    String lang = cells.next().toString();
    if (mMapping != null && mMapping.containsKey(lang)) {
      lang = mMapping.get(lang);
    }
    generateLang(sheet, lang, i);
    i++;
  }
}

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

private List<Variant> readRow(Row row) {
  Iterator<Cell> iterator = row.cellIterator();
  List<Variant> rowOut = new ArrayList<>();
  while (iterator.hasNext()) {
    Cell c = iterator.next();
    while (c.getColumnIndex() > rowOut.size()) {
      rowOut.add(null);
    }
    Variant val = new Variant(c);
    rowOut.add(val.isEmpty() ? null : val);
  }
  return rowOut;
}

代码示例来源:origin: org.molgenis/molgenis-one-click-importer

@Override
public List<DataCollection> buildDataCollectionsFromExcel(List<Sheet> sheets) {
 List<DataCollection> dataCollections = newArrayList();
 sheets.forEach(
   sheet -> {
    List<Column> columns = newArrayList();
    Row headerRow = sheet.getRow(0);
    headerRow
      .cellIterator()
      .forEachRemaining(cell -> columns.add(createColumnFromCell(sheet, cell)));
    dataCollections.add(DataCollection.create(sheet.getSheetName(), columns));
   });
 return dataCollections;
}

代码示例来源:origin: qcadoo/mes

private void autoSizeColumn(XSSFSheet sheet) {
  Row row = sheet.getRow(0);
  Iterator<Cell> cellIterator = row.cellIterator();
  while (cellIterator.hasNext()) {
    Cell cell = cellIterator.next();
    int columnIndex = cell.getColumnIndex();
    sheet.autoSizeColumn(columnIndex);
  }
}

代码示例来源:origin: stackoverflow.com

Iterator<Row> rowIterator = mySheet.iterator(); // Traversing over each row of XLSX file
   while (rowIterator.hasNext()) {
     Row row = rowIterator.next(); // For each row, iterate through each columns
     Iterator<Cell> cellIterator = row.cellIterator();
     while (cellIterator.hasNext()) {
       Cell cell = cellIterator.next();
       println "column index"+cell.getColumnIndex()//You will have your columns fixed in Excel file
       if(cell.getColumnIndex()==3)//for example of c
       {
       print "done"            
       }
    }
  }

代码示例来源:origin: stackoverflow.com

for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) {
     Row row = rit.next();
     String[] cells = new String[row.getPhysicalNumberOfCells()];
     int i = 0;
     for (Iterator<Cell> cit = row.cellIterator(); cit.hasNext();) {
       Cell cell = cit.next();
       cell.setCellType(Cell.CELL_TYPE_STRING);
       cells[i++] = cell.getStringCellValue();
     }
     // At this point you can put the values of the cells in
     // your map entry.
     System.out.println(Arrays.toString(cells);
   }

代码示例来源:origin: stackoverflow.com

for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) {
       Row row = rit.next();
       for (Iterator<Cell> cit = row.cellIterator(); cit.hasNext();) {
         Cell cell = cit.next();
         cell.setCellType(Cell.CELL_TYPE_STRING);
         mat = cell.getStringCellValue();
         thick = cell.getStringCellValue();
         size = cell.getStringCellValue();
         lbsPerSheet = cell.getStringCellValue();
         lbs = cell.getStringCellValue();
         System.out.println("Mat "+mat+" Thick "+ thick+" Size "+size+" lbs Per Sheet "+lbsPerSheet+" lbs "+lbs+ "\t");
       }
       System.out.println();
     }

代码示例来源:origin: TomasKypta/android-lang-tool

private void copyRow(Row inTitleRow, HSSFRow outRow) {
    // TODO copy formatting
    Iterator<Cell> it = inTitleRow.cellIterator();
    while (it.hasNext()) {
      Cell srcCell = it.next();
      outRow.createCell(srcCell.getColumnIndex(), srcCell.getCellType());
      outRow.getCell(srcCell.getColumnIndex()).setCellValue(srcCell.getStringCellValue());
    }
  }
}

代码示例来源:origin: stackoverflow.com

CellStyle centeredStyle = workbook.createCellStyle();
centeredStyle.setAlignment(CellStyle.ALIGN_CENTER);

CellStyle leftStyle = workbook.createCellStyle();
leftStyle.setAlignment(CellStyle.ALIGN_LEFT);

Sheet sheet = workbook.getSheetAt(0);
for(Row row : sheet.rowIterator()) {
  for(Cell cell : row.cellIterator()) {
    CellStyle cellStyle = (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) ? centeredStyle : leftStyle;
    cell.setCellStyle(cellStyle);
  }
}

相关文章