Rico Shurui
Rico Shurui

Reputation: 21

Ignore empty cells with phpexcel

i'm really new with PHPExcel library,and i'm new with this kind of programming. So my problem is i just wanna read a cells with a value in it, and ignore all the empty cell below my tables. can i do that? My Excel file:

enter image description here

I know this question is simillar to this Ignore empty cells PHPExcel thread, but i can't find the answer there, so please can someone help me..

My code for converting excel:

enter image description here

Upvotes: 1

Views: 2251

Answers (1)

ablopez
ablopez

Reputation: 850

Just add a validation inside the 2nd loop to check if all the required columns are empty, and if they're, skip that iteration. Example:

// Skip the iteration if all the required columns are empty
if(ltrim($aop_part_num) == '' && ltrim($type) == '' && ltrim($brand) == '' && ltrim($jumlah) == '') continue;

However, if the Excel file may have some more stuff below that table you're parsing (even if it has blank space in between), then replace the "continue" for a "break" to quit the loop and prevent that extra stuff from showing up in the echo statements.

Upvotes: 2

Related Questions