I am using CGRIDVIEW ... I hav fixed the column size to fixed width(for that I am using tag in the 'value' key of array ) .. now I want to export this Grid Results into a CSV file ... Its fine with the Exporting option ... but the problem is I get tags written into the CSV file ... How do i tackle this problem ?
View is =>
$this->widget('bootstrap.widgets.TbGridView', array(
'type' => 'bordered striped',
'id' => 'bike_search',
'dataProvider' => $model->search_bike(),
'ajaxUpdate' => true,
'filter' => null,
'template'=>'<div style="overflow:auto;">{items}</div>{pager}{summary}',
'columns' => $selected_columns,
'enablePagination' => true
));
Model Is ->
$selected_columns[] = array(
'header' => 'Name',
'name' => 'bike_name',
'type'=>'html',
'htmlOptions'=>array('style'=>'word-wrap: break-word;'),
'headerHtmlOptions'=>array('style'=>'text-align:center;'),
'value'=> '"<div style=\"width:100px;\">" . $data["bike_name"]. "</div>"',
);
Try to set content type="text/csv" on your csv exporting functionality
I came up with the solution ...
In the Controller function to export CSV .. I added strip_tags() to the returning data array
fputcsv(filename, strip_tags($data));
And Problem solved!