I currently have a return that sends back a list of items in an auction. What I am trying to do is clean up the array before I export it to a excel spread sheet. I can use yii or php to clean up the select before exporting, I just need to know how to do it. I know how to do it with a mysql statement but that is frowned upon in the yii world.
This is my current code:
$auction = Btmauctions::model()->findByPk($id);
$listings = $auction->btmListings;
$filename = 'last_lot_export.csv';
$csv = new ECSVExport($listings);
$csv->toCSV($filename); // returns string by default
Yii::app()->getRequest()->sendFile( $auction->name.'_lots.csv' , file_get_contents( $filename ) );
This exports a csv that looks like this:
ID auction_ID lot description manufacturer model more_info condition
21 10 12 FANUC CIRCUIT BOARD Fanuc A20B-9000-0180/09C 3
20 10 1 FANUC CIRCUIT BOARD Fanuc A20B-0008-0242/023A 4
22 10 18 FANUC CIRCUT BOARD Fanuc A20B-1003-0010/12B * A LITTLE DIRTY 3
23 10 19 FANUC CIRCUIT BOARD Fanuc A20B-1003-0020/03A *VERY DIRTY!!! *PLASTIC BROKEN ON RISERS!! COSMETIC ONLY!! 3
What I need to do is clean up the cvs automatically before exporting it so it looks like this:
lot INFO manufacturer model more info condition
12 FANUC CIRCUIT BOARD Fanuc A20B-9000-0180/09C 3
1 FANUC CIRCUIT BOARD Fanuc A20B-0008-0242/023A 4
18 FANUC CIRCUT BOARD Fanuc A20B-1003-0010/12B * A LITTLE DIRTY 3
19 FANUC CIRCUIT BOARD Fanuc A20B-1003-0020/03A *VERY DIRTY!!!
Aucun commentaire:
Enregistrer un commentaire