Generating an excel sheet under Codeigniter with special chars & empty properties

Topics: User Forum
Sep 22, 2013 at 7:58 PM
Using PHP Version 5.2.17, Codeigniter 2.1.3 & PHPExcel 1.7.8 under windows/apache I have the following issue:

If i run the script "01simple-download-xls.php" included in examples directory of PHPExcel, it runs correctly generating the expected file with cols, rows & xls file properties as defined in the script.

When i try to integrate this file into Codeigniter in order to test, the same script generates an sheet with garbaje or spaecial characters like that:
ÐÏࡱá;þÿ
þÿÿÿ þÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.

I decided to implement integation of PHPExcel in CI via $this->load->view method.

The directory structure is as follow:

Controller
-- Simple_controller

Views

01simple-download-xls.php (script to be tested under CI)
-- Classes
------ Phpexcel.php
------ PHPexcel (directory)

The code of simple_controller is:
<?php
class Simple_controller extends CI_Controller {
    function __construct()
    {
        parent::__construct();
    }
    function index()
    { 
        $this->load->view('01simple-download-xls'); 
    }
}
The code of 01simple-download-xls is the same as original source. The only difference is in the line where require PHPEcel library.
require_once 'Classes/PHPExcel.php';
At the of this file i changed this lines in order to get an xls file:
__header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="01simple.xls"');
header('Cache-Control: max-age=0');__

header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
I have tested differents procedures/tutorials. i.e.

1) http://www.ahowto.net/php/easily-integrateload-phpexcel-into-codeigniter-framework (PHPExcel as thirdparty libraries)

2) http://ellislab.com/forums/viewthread/215955/#998608 (PHPEXcel under libraries)

3) Invoking as a view the script wich generates excel file as decribed in this post.

Theses three procedures generates the same xls file with special characters and file properties in blank.

I'll be grateful If someone has the solution to this issue

Thanks

Campo
Feb 4, 2015 at 6:20 AM
Edited Feb 4, 2015 at 6:21 AM
Hi ocupado,

Did you resolved the problem, if yes please tell me the solution, I am also getting the same issue.
Feb 4, 2015 at 6:21 AM
Hi ocupado,

Did you resolved the problem, if yes please tell me the solution, I am also getting the same issue.