use of org.odftoolkit.odfdom.doc.table.OdfTableCell in project structr by structr.
the class ODSExporter method writeCollectionToCells.
static void writeCollectionToCells(final OdfTable sheet, final OdfTableCell startCell, final Collection col) {
int rowIndex, colIndex;
colIndex = startCell.getColumnIndex();
rowIndex = startCell.getRowIndex();
Iterator<Collection> colIt = col.iterator();
while (colIt.hasNext()) {
Object obj = colIt.next();
if (obj instanceof String[]) {
String[] arr = (String[]) obj;
List<String> list = new ArrayList<>(Arrays.asList(arr));
StringJoiner sj = new StringJoiner(",");
list.forEach(s -> sj.add(s));
writeObjectToCell(sheet.getCellByPosition(colIndex, rowIndex), sj.toString());
} else if (obj instanceof Collection) {
Collection nestedCol = (Collection) obj;
StringJoiner sj = new StringJoiner(",");
nestedCol.forEach(s -> sj.add(s.toString()));
writeObjectToCell(sheet.getCellByPosition(colIndex, rowIndex), sj.toString());
} else {
writeObjectToCell(sheet.getCellByPosition(colIndex, rowIndex), obj);
}
rowIndex++;
}
}
Aggregations