I'm using kartik export
widget for exporting my grid view in excel
. I am able to export all the data but there is an issue, I have a column name imsi
which is in text, but after exporting it this column is having all the same numbers i.e. all the IMSI numbers are same. See below
Grid Columns
$gridColumns =[
[
'class'=>'kartik\grid\SerialColumn',
],
'id',
['attribute'=>'imsi','format'=>'text'],
'sim_number'
]
How can I set the correct format? Any help would be highly appreciated.
Cause your cell data (imsi) is number. excel or some other programs. when size of cell is fewer than lenght of number. they change number to Scientific number or some thing like this.
to prevent from doing this. you must increase width of cell.
$gridColumns =[
['class'=>'kartik\grid\SerialColumn'],
'id',
[
'attribute'=>'imsi',
'vAlign'=>'middle',
'width'=>'200px',
'format'=>'raw',// or text
'value'=>function($model){
return $model->imsi.' ';
}
],
'sim_number'
]
update: after discussion. we found when we add spaces to value it will be force to text.
PS.
If you want to use this numbers from excel file. you must trim
to remove spaces.