Now we have a field list with all the field information we need. If we want field names on the first row of our csv file all we have to do is step through the field list and create the text. Here's how:
That's it for the field names. In my case, I left my field name delimiter empty. But I left in the code in case I need it somewhere down the road.
Extracting the Data
Next we need to extract our data and format it accordingly. We'll start with a common Mambo loadObjectList:
Now we need to step through each row to extact our data. We also need to step through each field so we can wrap it with our delimiter if needed. This is where the associated list comes in handy as we work with our field list. The code starts to get a little wordy here but it's all worth it in the long run. Here's the code:
The Zip File
We now have our entire csv text ready to export. In the next section, we'll create a temporary csv file we can use to create a zip file. Then we'll compress it using the pclZip library.
Click the Next Page link below to continue your journey.
Next Page: CSV Export Class - Zip File