Since the size () method exists with Arrraylist, to know the size of the elements.
Instead using apache then how can I know the cell size in excel, to know how many records there are?
public void fillDispositivoVeicoloIDVEICOLO() { for (int rowIndex = 1; rowIndex < 281 ; rowIndex++) { currentRow = dataTypeSheet.getRow(rowIndex); cell_id_veicolo = currentRow.getCell(8); // Cella I id_veicolo.add(cell_id_veicolo.getStringCellValue()); } System.out.println(id_veicolo); }
instead of 281 what should I put in it? given that in Excel there are 281 records?
--- Update ---
public void fillDispositivoVeicoloIDVEICOLO() { for (int rowIndex = 1; rowIndex < dataTypeSheet.getLastRowNum() ; rowIndex++) { currentRow = dataTypeSheet.getRow(rowIndex); cell_id_veicolo = currentRow.getCell(8); // Cella I id_veicolo.add(cell_id_veicolo.getStringCellValue()); } System.out.println(id_veicolo); }
Error:
Exception in thread "main" java.lang.NullPointerException
at it.cliente.Cliente.fillVeicoloId(Cliente.java:112)
at it.cliente.Test.main(Test.java:15)
dataTypeSheet.getLastRowNum() -->
returns me 1000
the error is here:
id_veicolo.add(cell_id_veicolo.getStringCellValue( ));
now it works but the problem is always the index
public void fillTarga() { for (int rowIndex = 1; rowIndex < dataTypeSheet.getPhysicalNumberOfRows(); rowIndex++) { currentRow = dataTypeSheet.getRow(rowIndex); cell_targa = currentRow.getCell(21); // Cella V if( cell_targa != null) targa.add(cell_targa.getStringCellValue()); } System.out.println(targa); } Error: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 12, Size: 12 at java.util.ArrayList.rangeCheck(ArrayList.java:657) at java.util.ArrayList.get(ArrayList.java:433) at it.cliente.Confrontare.confrontaTargheVeicolo(Confrontare.java:97) at it.cliente.Test.main(Test.java:10)