Welcome Guest, Not a member yet? Register   Sign In
Generate A Word Document
#1

[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.




Theme © iAndrew 2016 - Forum software by © MyBB