use of org.xlsx4j.sml.STCellType in project com.revolsys.open by revolsys.
the class XlsxRecordReader method readNextRow.
/**
* Reads the next line from the buffer and converts to a string array.
*
* @return a string array with each comma-separated element as a separate
* entry.
* @throws IOException if bad things happen during the read
*/
private List<String> readNextRow() {
if (this.rowIndex < this.rows.size()) {
final List<String> values = new ArrayList<>();
final Row row = this.rows.get(this.rowIndex);
final List<Cell> cells = row.getC();
for (final Cell cell : cells) {
String value = null;
final String cellValue = cell.getV();
final STCellType cellType = cell.getT();
switch(cellType) {
case S:
final int stringIndex = Integer.parseInt(cellValue);
final CTRst sharedString = this.sharedStringList.get(stringIndex);
final CTXstringWhitespace text = sharedString.getT();
value = text.getValue();
break;
default:
if (cellValue == null) {
final CTRst is = cell.getIs();
if (is != null) {
value = is.getT().getValue();
}
} else {
value = cellValue;
}
break;
}
final int columnIndex = getColumnIndex(cell);
if (columnIndex == -1) {
values.add(value);
} else {
while (values.size() < columnIndex) {
values.add(null);
}
values.add(columnIndex, value);
}
}
this.rowIndex++;
return values;
} else {
throw new NoSuchElementException();
}
}
Aggregations