Search in sources :

Example 16 with OdfTableCell

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++;
    }
}
Also used : StructrApp(org.structr.core.app.StructrApp) Arrays(java.util.Arrays) SecurityContext(org.structr.common.SecurityContext) HashMap(java.util.HashMap) OdfSpreadsheetDocument(org.odftoolkit.odfdom.doc.OdfSpreadsheetDocument) OdfTable(org.odftoolkit.odfdom.doc.table.OdfTable) OdfTableCell(org.odftoolkit.odfdom.doc.table.OdfTableCell) ArrayList(java.util.ArrayList) File(org.structr.web.entity.File) FrameworkException(org.structr.common.error.FrameworkException) App(org.structr.core.app.App) StringProperty(org.structr.core.property.StringProperty) Map(java.util.Map) URI(java.net.URI) GraphObjectMap(org.structr.core.GraphObjectMap) Result(org.structr.core.Result) AbstractNode(org.structr.core.entity.AbstractNode) JsonObjectType(org.structr.schema.json.JsonObjectType) Iterator(java.util.Iterator) Collection(java.util.Collection) GraphObject(org.structr.core.GraphObject) List(java.util.List) JsonSchema(org.structr.schema.json.JsonSchema) StringJoiner(java.util.StringJoiner) Entry(java.util.Map.Entry) VirtualType(org.structr.transform.VirtualType) SchemaService(org.structr.schema.SchemaService) ArrayList(java.util.ArrayList) Collection(java.util.Collection) GraphObject(org.structr.core.GraphObject) StringJoiner(java.util.StringJoiner)

Aggregations

OdfTableCell (org.odftoolkit.odfdom.doc.table.OdfTableCell)16 OdfTable (org.odftoolkit.odfdom.doc.table.OdfTable)14 AtividadesEnsinoService (com.tomasio.projects.trainning.interfaces.AtividadesEnsinoService)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)4 OrganizationalService (com.tomasio.projects.trainning.interfaces.OrganizationalService)4 List (java.util.List)4 OdfTableRow (org.odftoolkit.odfdom.doc.table.OdfTableRow)4 Cell (com.google.refine.model.Cell)3 Recon (com.google.refine.model.Recon)3 TurmaDTO (com.tomasio.projects.trainning.dto.TurmaDTO)3 Map (java.util.Map)3 AnotacaoDTO (com.tomasio.projects.trainning.dto.AnotacaoDTO)2 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)2 FolhaRostoDTO (com.tomasio.projects.trainning.dto.FolhaRostoDTO)2 TurmaPlanejadaDTO (com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)2 FileNotFoundException (java.io.FileNotFoundException)2 SimpleDateFormat (java.text.SimpleDateFormat)2