Welcome Guest, Not a member yet? Register   Sign In
how to export html table to excel || new question -> how to export rows generated by mysql queries to excel??
#7

[eluser]dcunited08[/eluser]
I wrote a method for MY_Table that should allow you to output the table as a csv, please give it a try and let me know if it works for you.

Code:
/**
     * Creates a csv string from the created table
     *
     * @author dcunited08 of CodeIgniter
     *
     * @param array $table_data
     * @return string
     */
    function generate_cvs($table_data = NULL)
    {
        //save current template
        $template_holder = $this->template;

        
        $tmpl = array (
                    'table_open'          => '',

                    'heading_row_start'   => '',
                    'heading_row_end'     => '',
                    'heading_cell_start'  => '',
                    'heading_cell_end'    => ',',

                    'row_start'           => '',
                    'row_end'             => '',
                    'cell_start'          => '',
                    'cell_end'            => ',',

                    'row_alt_start'       => '',
                    'row_alt_end'         => '',
                    'cell_alt_start'      => '',
                    'cell_alt_end'        => ',',

                    'table_close'         => '');
        
        //apply csv template
        $this->set_template($tmpl);
        
        //generate csv data
        $forReturn = $this->generate($table_data);
        
        //reset to old template
        $this->set_template($template_holder);
        
        return $forReturn;
    }


Messages In This Thread
how to export html table to excel || new question -> how to export rows generated by mysql queries to excel?? - by El Forum - 11-07-2008, 03:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB