EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kiran1234 on January 19, 2016, 03:15:33 AM



Title: Export to Excel the loaded data in datagrid
Post by: kiran1234 on January 19, 2016, 03:15:33 AM
I tried the topics posted in the forum, but non was helpful. Is there any other solution to export the data from datagrid with same format to excel. Please help. Need header and data. Thanks.


Title: Re: Export to Excel the loaded data in datagrid
Post by: ehussain on January 19, 2016, 04:22:44 AM
try phpExcel

https://phpexcel.codeplex.com/wikipage?title=Examples&referringTitle=Home

I can help if you want to do phpExcel.

Ejaz


Title: Re: Export to Excel the loaded data in datagrid
Post by: kiran1234 on January 19, 2016, 06:50:30 AM
Hi, I have configured with PHPExcel.

Its working well.  But I'm unable to get column names as header. Can u please help.

$q = mysql_query("select * from mytable");

while($mrow = mysql_fetch_assoc($q)) {
    $col = 0;
    foreach($mrow as $key=>$value) {
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, 0, $key);
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row + 1, $value);
        $col++;
    }
    $row++;
 }



Title: Re: Export to Excel the loaded data in datagrid
Post by: ehussain on January 19, 2016, 02:14:52 PM
$q = mysql_query("select * from mytable");

while($mrow = mysql_fetch_assoc($q)) {
    $col = 0;
    foreach($mrow as $key=>$value) {
        $objPHPExcel->setActiveSheetIndex(0)->setCellValueByColumnAndRow($col, 0, $key);
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row + 1, $value);
        $col++;
    }
    $row++;
 }