【问题标题】:codeigniter convert excel file to pdfcodeigniter将excel文件转换为pdf
【发布时间】:2014-12-03 08:52:07
【问题描述】:

我想问怎么把excel转成pdf?

我想放5个excel文件,点击上传后转换成1个pdf?

现在我在这段代码中使用:

    /**
 * 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");

}

图书馆:

类 Dompdf_gen {

public function __construct() {

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

    $pdf = new DOMPDF();

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

}

}

【问题讨论】:

  • 可能重复,这个答案可能对你有帮助stackoverflow.com/questions/23223491/…
  • 我看到了帖子但我不明白我的代码我上传文件 excel 并且在我打开文件并从 excel 中获取数据并放入 pdf 之后这可能吗?

标签: php excel codeigniter pdf


【解决方案1】:

首先,你必须将所有 excel 转储到 php 数组或 var 中,然后你可以根据需要创建 pdf,这是将 excel 转换为 pdf 的简单 php 脚本,你可以使用它并将其转换为子类代码点火器也是如此

请查看此网址

PHP read excel file

当您使用该课程时,您的 excel 数据将与您同在,因此您可以使用其他课程来处理 pdf,而该课程将为您提供帮助

codeigniter create PDF file

希望这对你有帮助。

【讨论】:

  • 我不明白这个问题。就像在这段代码中: $this->load->helper(array('dompdf', 'file')); // 这里的页面信息,数据库调用等 $html = $this->load->view('home', $data, true); pdf_create($html, '文件名') 或 $data = pdf_create($html, '', false); write_file('name', $data);我上传excel文件并将其覆盖为pdf后如何放置?此功能仅适用于 HTML
  • 您好,首先,将您的数据从 excel 转换为 php 数组或任何数据存储变量或数组或类,然后使用 pdf 类创建一个 pdf 文件,传递您从 excel 获得的数据转pdf类
【解决方案2】:

我不明白这个问题。 就像在这段代码中一样:

    $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);

我上传excel文件并将其覆盖为pdf后如何放置? 此功能仅适用于 HTML

【讨论】:

    猜你喜欢
    • 2016-04-07
    • 1970-01-01
    • 2012-11-30
    • 2013-10-05
    • 1970-01-01
    • 2019-06-03
    • 1970-01-01
    • 1970-01-01
    • 2013-08-10
    相关资源
    最近更新 更多