php - yii changing removing and renameing column names -


i have return sends list of items in auction. trying clean array before export excel spread sheet. can use yii or php clean select before exporting, need know how it. know how mysql statement frowned upon in yii world.

this current code:

$auction = btmauctions::model()->findbypk($id); $listings = $auction->btmlistings; $filename = 'last_lot_export.csv'; $csv = new ecsvexport($listings); $csv->tocsv($filename); // returns string default yii::app()->getrequest()->sendfile( $auction->name.'_lots.csv' , file_get_contents( $filename ) );  

this exports csv looks 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  * little dirty    3 23  10  19  fanuc circuit board fanuc   a20b-1003-0020/03a  *very dirty!!! *plastic broken on risers!! cosmetic only!!  3 

what need clean cvs automatically before exporting looks 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 * little dirty    3 19  fanuc circuit board  fanuc   a20b-1003-0020/03a *very dirty!!! 

to summarize changes, need delete first 2 columns, , rename 'description' column 'info'

should human readable headers

$headers = array('header_to_change'=>'new value'); $csv->setheaders($headers);  // or  $csv->setheader($currentheadervalue, $newheadervalue); 

and export columns want select columns. looks ecsvexport class use carraydataprovider input. therefore select columns want export , fill carraydataprovider , export class.

but can use "setcallback" function remove unwanted column entries or "setexclude" function. both functions there example in link given above.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -