even an empty excel file has a couple of thousand rows

so you need to query how many rows actually have data in them... or at least test for when the data stops.
I have never parsed excel spreadsheets but I guess you would watch for an empty cell to guess where the spreadsheet data is no more ... or set a flag.. this is a total guess by the way.
PHP Code:
while($x<=$excel->sheets[0]['numRows']) {
if(empty($excel->sheets[0]['cells'][$x][0])){
#first cell is empty , is this the end of the usable data ?
break;
}
... etc
also please stop with the massive red text, its annoying