本文整理汇总了Java中org.apache.poi.ss.usermodel.Row.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java Row.iterator方法的具体用法?Java Row.iterator怎么用?Java Row.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.Row
的用法示例。
在下文中一共展示了Row.iterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeRow
import org.apache.poi.ss.usermodel.Row; //导入方法依赖的package包/类
private void writeRow(final Row row, final XMLStreamWriter out, final Map<String, String> columns) {
try {
int rowIndex = row.getRowNum();
out.writeStartElement("row");
final String rowNum = String.valueOf(rowIndex);
out.writeAttribute("row", rowNum);
int count = 0;
Iterator<Cell> cellIterator = row.iterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
int columnIndex = cell.getColumnIndex();
if (this.exportEmptyCells) {
while (count < columnIndex) {
this.writeAnyCell(rowIndex, count, null, out, columns);
count++;
}
}
this.writeCell(cell, out, columns);
count++;
}
out.writeEndElement();
} catch (XMLStreamException e) {
e.printStackTrace();
}
}
示例2: parseRow
import org.apache.poi.ss.usermodel.Row; //导入方法依赖的package包/类
public void parseRow(Row row, SheetFormat sf, Object obj) throws RowParsingException {
Iterator<Cell> cellItr = row.iterator();
cellItr.next(); // for sr. no. column skip
for (ColumnFormat field : sf.getColumns())
if (cellItr.hasNext()) {
Cell cell = cellItr.next();
try {
set(obj, field.getName(), getValue(cell, field.getType()));
} catch (CellParsingException e) {
throw new RowParsingException(e.getMessage() + " , at row " + row.getRowNum());
}
}
}
示例3: writeFirstRow
import org.apache.poi.ss.usermodel.Row; //导入方法依赖的package包/类
/**
* Gets field names from column titles and writes the titles element with
* columns out
*
* @param row
* the row to parse
* @param columns
* the map with the values
*/
private void writeFirstRow(Row row, final XMLStreamWriter out, final Map<String, String> columns) {
Iterator<Cell> cellIterator = row.iterator();
int count = 0;
try {
out.writeStartElement("columns");
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
// Generate empty headers if required
if (this.exportEmptyCells) {
int columnIndex = cell.getColumnIndex();
while (count < columnIndex) {
String noLabel = "NoLabel" + String.valueOf(count);
columns.put(String.valueOf(count), noLabel);
out.writeStartElement("column");
out.writeAttribute("empty", "true");
out.writeAttribute("col", String.valueOf(count));
out.writeAttribute("title", noLabel);
out.writeEndElement();
count++;
}
}
final String cellValue = this.getCellValue(cell, count);
if (cellValue != null) {
columns.put(String.valueOf(cell.getColumnIndex()), cellValue);
out.writeStartElement("column");
out.writeAttribute("title", cellValue);
out.writeAttribute("col", String.valueOf(cell.getColumnIndex()));
out.writeEndElement();
}
count++;
}
out.writeEndElement();
} catch (XMLStreamException e) {
e.printStackTrace();
}
}