codeigniter convert excel file to pdf

2019-09-05 08:49发布

I want to ask how can I convert excel to pdf?

I want to put 5 excel files and after I click upload in convert to 1 pdf?

for now I use in this code:

    /**
 * Example: DOMPDF 
 *
 * Documentation: 
 * http://code.google.com/p/dompdf/wiki/Usage
 *
 */
public function index() {   
    // Load all views as normal
    $this->load->view('test');
    // Get output html
    $html = $this->output->get_output();

    // Load library
    $this->load->library('dompdf_gen');

    // Convert to PDF
    $this->dompdf->load_html($html);
    $this->dompdf->render();
    $this->dompdf->stream("welcome.pdf");

}

the library:

class Dompdf_gen {

public function __construct() {

    require_once APPPATH.'third_party/dompdf/dompdf_config.inc.php';

    $pdf = new DOMPDF();

    $CI =& get_instance();
    $CI->dompdf = $pdf;

}

}

2条回答
我命由我不由天
2楼-- · 2019-09-05 09:22

I do not understand the problem. like in this code:

    $this->load->helper(array('dompdf', 'file'));
    // page info here, db calls, etc.
    $html = $this->load->view('home', $data, true);
    pdf_create($html, 'filename')
    or
    $data = pdf_create($html, '', false);
    write_file('name', $data);

how i put after i upload excel file and cover it to pdf? this function is only for HTML

查看更多
太酷不给撩
3楼-- · 2019-09-05 09:23

first of things , you have to dump all excel to php array or var , after that you can create pdf as you want , this is simple php script for convert excel to pdf , you can use it and convert it to subclass of codeigniter as well

please check this url

PHP read excel file

when you use that class your excel data will be with you so you can use another class for pdf and this class will help you

codeigniter create PDF file

hopeful this is helpful for you .

查看更多
登录 后发表回答