java - How do I iterate all the rows in a spreadsheet (including null) -


i using apache poi parse excel spreadsheet. according poi iterator guide, row iterator skip rows null. wanted iterate rows, null or not. used loop instead.

            row row0 = sheet.getrow(0);             (row row : sheet)             {                 rowindex ++;                 cell cell = row.getcell(0);                 if (cell != null) {                      system.out.println(rowindex);                 }             } 

when debugged in eclipse, following spreadsheet, row0 null, row in first iteration of loop not null. output (row index of first not null cell) supposed 2, prints 1.

spreadsheet

debug in eclipse

why first null row skipped loop?

for loop (in case for-each loop) uses iterator (see iterable interface https://docs.oracle.com/javase/8/docs/api/java/lang/iterable.html) iterate through rows, have written skip null values.

the way include null values in iteration use traditional loop (see iterate on cells, control of missing / blank cells section in http://poi.apache.org/spreadsheet/quick-guide.html#iterator).


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -