Retreive column value based on cell value

Topics: Developer Forum, Project Management Forum, User Forum
Oct 21, 2010 at 7:16 AM


Basically, what I want to do is:


(I have following data in excel)

column_1 column_2

1             test 

2             test

3             bla

SELECT column_1 WHERE column_2 = "test" (Do something similar in SQL)


Can I do this in phpexcel?

Oct 22, 2010 at 9:13 AM

This functionality is not available in PHPExcel: you would have to write something to do this yourself.

I can think of two approaches: using the iterators (see 28iterator.php in the /Tests folder for an example) to loop through the rows and columns of a worksheet to find cells matching your data, and return a list of the matching cells.

If you want to do this as a SQL style query, there is a library called sql4array that allows you to execute SQL queries against 2-dimensional PHP arrays. Combine this with the result of calling a worksheet's toArray() method.