CodeIgniter Forums
Generate A Word Document - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Generate A Word Document (/thread-25559.html)



Generate A Word Document - El Forum - 12-16-2009

[eluser]merrick.christensen[/eluser]
Code:
function create_word()
    {
        $list = $this->springresearchconfmodel->listAbstracts();
    
        $word = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
        </head>
        <body>';
        
        foreach($list->result() as $abstract)
        {
            $co = '';
            
            if($abstract->co_presenters == '0')
            {
                $co = "";
            }
            else
            {
                $co = str_replace("|", "&", $abstract->co_presenters);
            }
                
            $page_data = array(
                'presenter_name' => $abstract->presenter_first . ' ' . $abstract->presenter_last,
                'co_presenters' => $co,
                'advisor' => $this->facultymodel->returnFaculty($abstract->faculty_advisor),
                'abstract_title' => $abstract->title_of_abstract,
                'abstract' => $abstract->abstract
            );
            
            $word .= $this->load->view('springresearchconference/src_word', $page_data);
        }
        
        $word .= '</body></html>';
        
        
        header("Content-type: application/vnd.ms-word");
        header("Content-Disposition: attachment;Filename=Spring Research Conference.doc");
        echo $word;
    }

I am trying to generate a word document. And it will load up fine in textedit or neo office but I'm getting an invalid file format error with Pages. And it just won't open with word. Any help would be greatly appreciated.