1

Here is my situation. I am having one excel sheet that contains 20000 records of different addresses. The data is mapped like this

+----+---------+-------+-------+-----+
| Sr | Addr 1  |Addr 2 | State | zip |
+----+---------+-------+-------+-----+

This is the sample data mapping. Now What I want is to create sub lists or sheets that are sorted according to specific column say Sheet 1 contains list sorted based on State column.

And sheet 2 sorted according to zip code.

How can I achieve this using PHPExcel Library?

Aatman
  • 573
  • 1
  • 5
  • 17
  • what have you done and tried so far? Please provide your code – DasSaffe Dec 07 '15 at 14:37
  • @DasSaffe I appreciate your concern, but the truth is I was so confused to try something so I asked question here for suggestions, will try and share the code if I face problems. – Aatman Dec 08 '15 at 04:57

1 Answers1

3

Depends how much memory you have - I'd use the Worksheet's toArray() method to copy the cells from the main sheet to a PHP array, then you can use usort() to sort that array however you like, then create a new worksheet and use fromArray() to populate it with the sorted data - but for 20,000 rows, you need enough memory to hold that data as an array in memory.

Mark Baker
  • 209,507
  • 32
  • 346
  • 385