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