error when saving vector in java

Asked

Viewed 27 times

1

This class has the function of storing data from an excel file in an array. But it is not doing so. Can anyone tell me why? I’ve asked a gender question before but I can’t edit it.

public class uni {

public static void main (String[] args) throws IOException{

    String[][] mat_Excel = new String[60][20];

    File excel = new File("gestao.xlsx");
    FileInputStream fich = new FileInputStream(excel);

    //através de biblioteca Poi da apache podemos ler o ficheiro excel
    XSSFWorkbook workbook = new XSSFWorkbook(fich);
    //temos acesso à folha de excel
    XSSFSheet sheet = workbook.getSheetAt(0);

    //iteramos as row da folha de excel
    Iterator<Row> rowIt = sheet.iterator();

    int linha=0, coluna=0;

    while(rowIt.hasNext()){
        Row row  = rowIt.next();
        //iteramos células que estão exatamente nesta row
        Iterator<Cell> cellIterator = row.cellIterator();          
        while(cellIterator.hasNext()){
            Cell cell = cellIterator.next();
            mat_Excel[coluna][linha] = cell.toString();
            //System.out.print(cell.toString() + ";");

            linha++;
        }
        coluna++;   
    }

    System.out.println(Arrays.toString(mat_Excel));
    System.out.println(Arrays.deepToString(mat_Excel));

    workbook.close();
    fich.close();

}
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.