Como posso ler as linhas(horizontalmente) do gráfico Excel?
Desta forma abaixo ele lê por colunas(verticalmente)
Iterator<Row> rowIterator = sheet2.iterator(); //sheet2 é uma planilha
ArrayList<String> addreesVectorSeries = new ArrayList<>();
ArrayList<String> addreesVectorCategory = new ArrayList<>();
while (rowIterator.hasNext()) { //varre as linhas
Row row2 = rowIterator.next();
Iterator<Cell> cellIterator = row2.cellIterator();
while (cellIterator.hasNext()) { //varre as celulas
Cell cell2 = cellIterator.next();
switch (cell2.getCellType()) { //verifica o tipo
case Cell.CELL_TYPE_NUMERIC:
break;
case Cell.CELL_TYPE_STRING:
if (cell2.getAddress().formatAsString().startsWith("A")) {
//System.out.println("str " + cell2.getAddress());
addreesVectorCategory.add(cell2.getAddress().formatAsString());
}
if (cell2.getAddress().formatAsString().startsWith("B")) {
larguraGrafico++;
addreesVectorSeries.add(cell2.getAddress().formatAsString());
}
break;
case Cell.CELL_TYPE_FORMULA:
//System.out.println("form " + cell2.getAddress());
if (cell2.getAddress().formatAsString().startsWith("B")) {
larguraGrafico++;
addreesVectorSeries.add(cell2.getAddress().formatAsString());
}
break;
}
}
}
exemplo