Example usage for org.apache.poi.ss.usermodel Cell getColumnIndex

List of usage examples for org.apache.poi.ss.usermodel Cell getColumnIndex

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell getColumnIndex.

Prototype

int getColumnIndex();

Source Link

Document

Returns column index of this cell

Usage

From source file:org.wandora.application.tools.extractors.excel.ExcelAdjacencyListExtractor.java

License:Open Source License

public void processRowAsRoles(Row row, TopicMap topicMap) {
    Iterator<Cell> cellIterator = row.cellIterator();
    while (cellIterator.hasNext()) {
        try {/*from ww  w  .  jav  a  2s  .  c om*/
            Cell cell = cellIterator.next();
            if (getCellValueAsString(cell) != null) {
                Topic cellTopic = getCellTopic(cell, topicMap);
                rolesPerColumn.put(Integer.toString(cell.getColumnIndex()),
                        cellTopic.getOneSubjectIdentifier().toExternalForm());
            }
        } catch (TopicMapException ex) {
            log(ex);
        } catch (Exception ex) {
            log(ex);
        }
    }
}

From source file:org.wandora.application.tools.extractors.excel.ExcelAdjacencyListExtractor.java

License:Open Source License

public Topic getDefaultRoleTopic(Cell cell, TopicMap tm) {
    int i = cell.getColumnIndex();
    Topic typeTopic = getOrCreateTopic(tm, DEFAULT_ROLE_TYPE_SI + "/" + i, "Excel role " + i);
    return typeTopic;
}

From source file:org.wandora.application.tools.extractors.excel.ExcelAdjacencyMatrixExtractor.java

License:Open Source License

public void processRow(Row row, TopicMap tm) {
    Association a = null;/*from   w w w . j a v a2 s  .  c  o m*/

    try {
        Cell firstColumnCell = row.getCell(0);
        if (firstColumnCell != null) {
            if (getCellValueAsString(firstColumnCell) != null) {
                Topic cellTopic = getCellTopic(firstColumnCell, tm);
                rowLabels.put(Integer.toString(firstColumnCell.getRowIndex()),
                        cellTopic.getOneSubjectIdentifier().toExternalForm());
            } else {
                return;
            }
        }

        Iterator<Cell> cellIterator = row.cellIterator();
        while (cellIterator.hasNext() && !forceStop()) {
            Cell cell = cellIterator.next();
            if (cell.getColumnIndex() > 0) {
                processCell(cell, tm);
            }
        }
    } catch (TopicMapException ex) {
        log(ex);
    } catch (Exception ex) {
        log(ex);
    }
}

From source file:org.wandora.application.tools.extractors.excel.ExcelAdjacencyMatrixExtractor.java

License:Open Source License

public void processCell(Cell cell, TopicMap tm) {
    if (cell != null) {
        try {//from  w  ww  .  j  a  v a2  s  .c o m

            String rowLabel = rowLabels.get(Integer.toString(cell.getRowIndex()));
            String columnLabel = columnLabels.get(Integer.toString(cell.getColumnIndex()));
            if (rowLabel != null && columnLabel != null) {
                if (hasValue(cell)) {
                    Topic rowTopic = tm.getTopic(rowLabel);
                    Topic columnTopic = tm.getTopic(columnLabel);
                    if (rowTopic != null && columnTopic != null) {
                        Association a = tm.createAssociation(getAssociationTypeTopic(cell, tm));
                        a.addPlayer(rowTopic, getRowTypeTopic(tm));
                        a.addPlayer(columnTopic, getColumnTypeTopic(tm));
                        if (ADD_CELL_VALUE_AS_PLAYER) {
                            Topic cellTopic = getCellTopic(cell, tm);
                            Topic cellType = getCellTypeTopic(tm);
                            if (cellTopic != null && cellType != null) {
                                a.addPlayer(cellTopic, cellType);
                            }
                        }
                        if (ADD_CELL_COLOR_AS_PLAYER) {
                            Topic cellColorTopic = getColorTopic(cell, tm);
                            Topic cellType = getColorTypeTopic(tm);
                            if (cellColorTopic != null && cellType != null) {
                                a.addPlayer(cellColorTopic, cellType);
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            log(e);
        }
    }
}

From source file:org.wandora.application.tools.extractors.excel.ExcelAdjacencyMatrixExtractor.java

License:Open Source License

public void processAsLabels(Row row, TopicMap topicMap) {
    Iterator<Cell> cellIterator = row.cellIterator();
    while (cellIterator.hasNext()) {
        try {/*  ww w.  j  ava2s.co  m*/
            Cell cell = cellIterator.next();
            if (getCellValueAsString(cell) != null) {
                Topic cellTopic = getCellTopic(cell, topicMap);
                columnLabels.put(Integer.toString(cell.getColumnIndex()),
                        cellTopic.getOneSubjectIdentifier().toExternalForm());
            }
        } catch (TopicMapException ex) {
            log(ex);
        } catch (Exception ex) {
            log(ex);
        }
    }
}

From source file:org.wandora.application.tools.extractors.excel.ExcelTopicNameExtractor.java

License:Open Source License

public void processRow(Row row, TopicMap tm) {
    try {//from   w w w .jav  a2 s  . c  o  m
        Iterator<Cell> cellIterator = row.cellIterator();
        Topic topic = null;
        Cell firstCell = row.getCell(0);
        if (getCellValueAsString(firstCell) != null) {
            topic = getCellTopic(firstCell, tm);
        }
        if (topic != null) {
            while (cellIterator.hasNext() && !forceStop()) {
                Cell cell = cellIterator.next();
                if (cell.getColumnIndex() != 0) {
                    String name = getCellValueAsString(cell);
                    if (name != null) {
                        String langSI = languagesPerColumn.get(Integer.toString(cell.getColumnIndex()));
                        Topic lang = tm.getTopic(langSI);
                        if (lang == null)
                            lang = getDefaultLanguageTopic(cell, tm);
                        HashSet scope = new LinkedHashSet();
                        scope.add(lang);
                        if (ADD_DISPLAY_TO_SCOPE)
                            scope.add(tm.getTopic(XTMPSI.DISPLAY));
                        if (ADD_SORT_TO_SCOPE)
                            scope.add(tm.getTopic(XTMPSI.SORT));
                        topic.setVariant(scope, name);
                    }
                }
            }
        }
    } catch (TopicMapException ex) {
        log(ex);
    } catch (Exception ex) {
        log(ex);
    }
}

From source file:org.wandora.application.tools.extractors.excel.ExcelTopicNameExtractor.java

License:Open Source License

public void processRowAsLanguages(Row row, TopicMap tm) {
    Iterator<Cell> cellIterator = row.cellIterator();
    while (cellIterator.hasNext()) {
        try {//from w w w.j  a  v  a2  s .c  o  m
            String langSI = null;
            Cell cell = cellIterator.next();
            String lang = getCellValueAsString(cell);
            if (lang != null) {
                Topic langTopic = tm.getTopicWithBaseName(lang);
                if (langTopic != null)
                    langSI = langTopic.getOneSubjectIdentifier().toExternalForm();
                else
                    langSI = XTMPSI.getLang(lang);
                langTopic = tm.getTopic(new Locator(langSI));
                languagesPerColumn.put(Integer.toString(cell.getColumnIndex()), langSI);

                if (langTopic == null && CREATE_MISSING_LANGUAGE_TOPICS) {
                    langTopic = tm.createTopic();
                    langTopic.addSubjectIdentifier(new Locator(langSI));
                    Topic langTypeTopic = tm.getTopic(XTMPSI.LANGUAGE);
                    if (langTypeTopic != null) {
                        langTopic.addType(langTypeTopic);
                    }
                }
            }
        } catch (Exception ex) {
            log(ex);
        }
    }
}

From source file:org.wandora.application.tools.extractors.excel.ExcelTopicNameExtractor.java

License:Open Source License

public Topic getDefaultLanguageTopic(Cell cell, TopicMap tm) {
    if (cell != null && tm != null) {
        int i = cell.getColumnIndex();
        Topic typeTopic = getOrCreateTopic(tm, DEFAULT_LANGUAGE_SI + "/" + i, "Excel language " + i);
        return typeTopic;
    }//from w w  w. j a v a2s  .co  m
    return null;
}

From source file:org.wandora.application.tools.extractors.excel.ExcelTopicOccurrenceExtractor.java

License:Open Source License

public void processRow(Row row, TopicMap tm) {
    try {/*  w  w w .j  a v a2s  .c  o m*/
        Iterator<Cell> cellIterator = row.cellIterator();
        Topic topic = null;
        Cell firstCell = row.getCell(0);
        if (getCellValueAsString(firstCell) != null) {
            topic = getCellTopic(firstCell, tm);
        }
        if (topic != null) {
            while (cellIterator.hasNext() && !forceStop()) {
                Cell cell = cellIterator.next();
                if (cell.getColumnIndex() > 0) {
                    String occurrence = getCellValueAsString(cell);
                    if (occurrence != null) {
                        Topic type = null;
                        String typeSI = occurrenceTypes.get(Integer.toString(cell.getColumnIndex()));
                        if (typeSI != null)
                            type = tm.getTopic(typeSI);
                        if (type == null)
                            type = getDefaultOccurrenceTypeTopic(cell, tm);
                        topic.setData(type, tm.getTopic(XTMPSI.getLang(DEFAULT_LANG)), occurrence);
                    }
                }
            }
        }
    } catch (TopicMapException ex) {
        log(ex);
    } catch (Exception ex) {
        log(ex);
    }
}

From source file:org.wandora.application.tools.extractors.excel.ExcelTopicOccurrenceExtractor.java

License:Open Source License

public void processRowAsOccurrenceTypes(Row row, TopicMap topicMap) {
    Iterator<Cell> cellIterator = row.cellIterator();
    while (cellIterator.hasNext()) {
        try {/*from  w  w  w  .j ava2  s. c  o m*/
            Cell cell = cellIterator.next();
            if (getCellValueAsString(cell) != null) {
                Topic cellTopic = getCellTopic(cell, topicMap);
                occurrenceTypes.put(Integer.toString(cell.getColumnIndex()),
                        cellTopic.getOneSubjectIdentifier().toExternalForm());
            }
        } catch (TopicMapException ex) {
            log(ex);
        } catch (Exception ex) {
            log(ex);
        }
    }
}