Linesofcode
Linesofcode

Reputation: 5891

PHPExcel unknown characters

I've followed some tutorials and saw some people with same issue but I can't figure out how to put this working on my project.

Btw, I'm using CodeIgniter framework and I have Excel 2007 in my computer.

public function exportExcel(){

    require(APPPATH . 'libraries/toExcel/PHPExcel.php');
    $objPHPExcel = new PHPExcel();

    $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue('A1', 'Hello');

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

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

    header('Content-Type: application/vnd.ms-excel; charset=utf-8');
    header('Content-Disposition: attachment; filename=01simple.xls');
    header('Cache-Control: max-age=0');

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

    exit;
}

This is my code just for testings. Whenever I download the file generated by that function and try to open it is this what I get: enter image description here

And when I click "Yes" I receive this:

enter image description here

Upvotes: 0

Views: 4164

Answers (2)

heyder mustafayev
heyder mustafayev

Reputation: 1

All php_excel changed Unknown Creator worksheet. directory application/third_party/phpexcel/PHPExcel/DocumentProperties.php changed line 43;

private $creator = 'Unknown Creator'; changed ↓
private $creator = 'your name';

Upvotes: 0

Linesofcode
Linesofcode

Reputation: 5891

Solved.

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

Upvotes: 8

Related Questions