There is an example of how to do this in the Facilities application.
Tthe The example is at https://demo-trunk.ofbiz.apache.org/facility/control/ViewFacilityInventoryByProduct?facilityId=WebStoreWarehouse.
You need to generate the list by using the "Find" button before exporting using the "Export" button.
...