Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Jqgrid table export to excel
17/01/2012
18:39
Avatar
khurram_619
New Member
Members
Forum Posts: 1
Member Since:
17/01/2012
sp_UserOfflineSmall Offline

hiiii

i try to export jqgrid table into excel file, but i have an error.
THIS IS MY CODE

JS


function jqgridtable()
{    
    var url='index.php?r=advertise/tableJSON';
    
    $.ajax({
       type: "GET",
       url: url, 
       dataType: "json",
       success: function(result){
           var   table='list',
                 pager='pager',

                   colM = result.colModelList,
                   cap  = result.caption;
                   colN = result.columnNames;
                   rowS = result.rows;
                  listjqgrid(table,pager,colN,colM,rowS,cap);

                  jQuery("#"+table).jqGrid('navButtonAdd','#'+pager,{
                           title:'export to excel',
                           buttonicon:'ui-icon-newwin',
                            onClickButton : function () { 
                                  $.post('index.php?r=advertise/excel', {r:rowS, n:colN});    
                               }
                   });
       }
        
    });
}

phpfile

       $names=$_REQUEST['n'];
        $rows=$_REQUEST['r'];
        
        error_reporting(E_ALL);

        $phpExcelPath = Yii::getPathOfAlias('ext.phpexcel.Classes');
        spl_autoload_unregister(array('YiiBase','autoload')); 
        include($phpExcelPath . DIRECTORY_SEPARATOR . 'PHPExcel.php');

        $objPHPExcel = new PHPExcel();

        //Set properties
        $objPHPExcel->getProperties()->setCreator("Khurram Bashir")
                    ->setTitle("Office 2007 XLS Test Document")
                    ->setSubject("Office 2007 XLS Test Document")
                    ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
                    ->setKeywords("office 2007 php")
                    ->setCategory("Test result file");

        $objPHPExcel->setActiveSheetIndex(0)
                    ->setCellValue('A1', 'hi')
                    ->setCellValue('A2', 'hiiii')
                    ->setCellValue('B1', 'hi')
                    ->setCellValue('B2', 'hiiiii');
                    
        

        // Rename sheet
        $objPHPExcel->getActiveSheet()->setTitle('Simple');

        // Set active sheet index to the first sheet, so Excel opens this as the first sheet
        $objPHPExcel->setActiveSheetIndex(0);
        
        // Redirect output to a client’s web browser (Excel5)
        header('Content-Type: application/vnd.ms-excel');
        header("Content-Type: application/force-download");
        header('Content-Disposition: attachment;filename="01simple.xls"');
        header("Pragma: ");  
        header("Cache-Control: "); 
        
        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
        
        $objWriter->save('php://output');
        Yii::app()->end();
        
       // Once we have finished using the library, give back the 
       // power to Yii... 
       spl_autoload_register(array('YiiBase','autoload'));
    }

after execute this code don't give me code error and not out to save the file.

i have watched with Firebug and give me a response

��ࡱ�;'��     �������� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������    �
��B�=�%r8X"1��Calibri��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    ��� �    � �    �����8�������������������������������3f������ff���f����������������������������������̙��̙3f�3���������fff����3f3�f333�3�3f33�333�'Simple��g���ciao

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
44 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information