You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by narendra nath <na...@yahoo.co.in> on 2012/11/23 12:03:23 UTC

getPhysicalNumberOfRows value is different from XLS files to XLSX files

Hi ,

    I am trying to upload XLS and XLSX files , and before processing I kept
a check whether are there any rows existed other than header row. To
determine this I used getPhysicalNumberOfRows() function , to know no. of
rows existed in file. But , it is giving different value for XLS and XLSX
file.

Below is the code snippet ...

Workbook workbook = WorkbookFactory.create(uploadBO.getFile()); 
Sheet sheet = workbook.getSheetAt(0);

if(sheet.getPhysicalNumberOfRows()<=1)
			throw new Exception("No data exists in file");

So, Pl. let me know how to proceede on this.

Note :Also enclosed the XLS and XLSX files for your reference.

Thanks
Naren BUG_418_Issue_1.xlsx
<http://apache-poi.1045710.n5.nabble.com/file/n5711535/BUG_418_Issue_1.xlsx>  
BUG_235_ACE_Book1.xls
<http://apache-poi.1045710.n5.nabble.com/file/n5711535/BUG_235_ACE_Book1.xls>  



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/getPhysicalNumberOfRows-value-is-different-from-XLS-files-to-XLSX-files-tp5711535.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getPhysicalNumberOfRows value is different from XLS files to XLSX files

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
What issue are you talking about, whether there are rows other than the
header? If it were me, I would simply check, get the Iterator for any and
all of the rows on the sheet and look at the rows in order to determine just
what they contain. If you have a non header row that contains anything other
than blank cells then...



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/getPhysicalNumberOfRows-value-is-different-from-XLS-files-to-XLSX-files-tp5711535p5711569.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getPhysicalNumberOfRows value is different from XLS files to XLSX files

Posted by narendra nath <na...@yahoo.co.in>.
Thanks for the reply Mark !!
So, what could be the best approach to resolve this type of issues.




--
View this message in context: http://apache-poi.1045710.n5.nabble.com/getPhysicalNumberOfRows-value-is-different-from-XLS-files-to-XLSX-files-tp5711535p5711568.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: getPhysicalNumberOfRows value is different from XLS files to XLSX files

Posted by Mark Beardsley <ma...@tiscali.co.uk>.
The answer to this depends very much upon how the files were created - if
they are EXACT copies of one another aside from the format then the physical
number of rows may well match, otherwise it might not.

Sounds silly I know but Excel will store a row in the file if a single cell
on that row has been 'touched' to use another strange term. Say the user
created a cell on a row and then deleted it again, Excel MAY still store the
record for the row in the file even though it appears to be empty. Without
digging into the structure of the two example files you supplied I suspect
that this could very well be the reason for the discrepancy.





--
View this message in context: http://apache-poi.1045710.n5.nabble.com/getPhysicalNumberOfRows-value-is-different-from-XLS-files-to-XLSX-files-tp5711535p5711547.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org