M
M
Maxim2016-01-28 15:23:09
CodeIgniter
Maxim, 2016-01-28 15:23:09

PHPExcel Codeigniter not working?

There is a piece of code:

header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" );
        header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" );
        header ( "Cache-Control: no-cache, must-revalidate" );
        header ( "Pragma: no-cache" );
        header ( "Content-type: application/vnd.ms-excel" );
        header ( 'Content-Disposition: attachment; filename="fname.xls"' );
        $objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
        $objWriter->save('php://output');
        echo 1;

The problem is that it gives out a bunch of hieroglyphs, how to fix it?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri, 2016-01-28
@riky

I have added coding

header('Content-Type', 'text/vnd.ms-excel; charset=utf-8');

D
dmitriy, 2016-01-28
@dmitriylanets

I have output like this:

$filename='invoice.xlsx'; 
    header('Content-Type: application/vnd.openxmlformats-officedocument.excelprocessingml.document'); 
    header('Content-Disposition: attachment;filename="'.$filename.'"'); 
    header('Cache-Control: max-age=0'); //no cache
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

    $objWriter->save('php://output');	
    
    die();

M
Maxim Smirnov, 2016-02-04
@MaxiStyle

Instead of echo 1, you need to insert exit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question