Salesforce's reporting transformer can also be used to produce a report, you'll want something similar to this:

Except you need the list in the code for some reason (for instance, for integration with another system) then you should use the reporting engine and then you can schedule it for email delivery, etc.