Welcome Guest, Not a member yet? Register   Sign In
converted to_excel plugin to helper to work in CI 2.0
#11

[eluser]swetha[/eluser]
I used the plugin to copy a table into an excel file. But it didn't work. I got "404 page not found error". I somehow didn't get any download request or a file downloaded.
can someone help me with this please?

What I actually need:
Need to export certain rows from a table into an Excel file.
#12

[eluser]Brad K Morse[/eluser]
Sure thing, paste your controller, view, model code, using the code tags and we'll see what we can do to get this working.
#13

[eluser]swetha[/eluser]
The following are the code snippets..

Code:
/*export_view.php*/

<?php foreach($q as $row)
         print $row->fest_id;
         print $row->fest_name;
?>
<a >fest_id?&gt;/&lt;?=$row->fest_name?&gt;">Export</a>

          
/*export.php -- controller*/
function event_list()
    {
            $this->load->model('admin/export_model');
            $data['q']=$this->export_model->backup();
            $this->load->view('admin/export_view',$data);
    }
    
    function export_contacts($fest_id='',$fest_name='')
    {
        $this->load->database();
        $this->load->plugin('to_excel');
    
        $this->db->use_table('contacts');
        $this->db->select('*');

        $query = $this->db->query('SELECT * FROM contacts where fest_id=$fest_id');
       $filen=to_excel($query,$fest_name);
      
    }
/*export_model.php*/
function backup()
    {
         $this->load->database();
         $q=$this->db->get('fest');
         return $q->result();
  
    }
What is it that is wrong with this that I face the page not found error?? Need quick help..

Url where i get a 404 error : http://localhost/admin/export_contacts/1/fiesta
#14

[eluser]Brad K Morse[/eluser]
Revise your previous by placing your blocks of code within the code tags, like seen here: http://pastie.org/2038368

What is the URL you are getting a 404 at, just so I can confirm that your controller and methods match your URL
#15

[eluser]swetha[/eluser]
Successfully I am able to download files :-) but now I happen to encounter a different problem.. The tables are not getting exported :-( the excel file on opening pops up with a message saying the file is corrupted..
FYI I use Microsoft Excel 2007.

Any help would be appreciated.
#16

[eluser]Brad K Morse[/eluser]
Try hard coding the id into the query and don't pass any parameters into your export_contacts function
#17

[eluser]swetha[/eluser]
well.. i would require the id from the view page only as I need to export the table based on the fest_id the user clicks on.. can you please tell me a way out of this?
#18

[eluser]swetha[/eluser]
well.. i would require the id from the view page only as I need to export the table based on the fest_id the user clicks on.. can you please tell me a way out of this?
#19

[eluser]Brad K Morse[/eluser]
Create a new function, with the id hard coded in there, don't pass it via the URL, just so we can narrow down what might be happening, this will help determine your query is returning results.
#20

[eluser]swetha[/eluser]
Thanks a lot Smile it worked .. I got it.. ! but wouldn't this helper work for Excel version 2007??




Theme © iAndrew 2016 - Forum software by © MyBB