2014-10-08 154 views
0

我想問如何將excel轉換爲pdf?codeigniter將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; 

} 

}

+1

可能重複,這個答案可能會幫助你http://stackoverflow.com/questions/23223491/how-to-convert-xls-to-pdf-via-php – veedubrob2014 2014-10-08 16:12:34

+0

我看到帖子但我不明白關於我的代碼ii上傳文件的Excel和我打開文件後,從Excel中取出數據並放在PDF中這可能嗎? – idan003 2014-10-09 07:23:01

回答

0

第一的東西,你必須轉儲全部excel到php數組或var,之後你可以創建PDF,只要你想,這是一個簡單的PHP腳本RT擅長爲PDF格式,你可以用它並將其轉換成笨的子類,以及

請查看此網址

PHP read excel file

當您使用的類Excel數據將與你,讓你可以使用另一個類的PDF和這個類可以幫助你

codeigniter create PDF file

希望這是對你有幫助。

+0

我不明白這個問題。像在這樣的代碼: $這 - >負載>輔助(陣列( 'DOMPDF', '文件')); //網頁上的信息在這裏,分貝調用等 $的HTML = $這個 - >負載>視圖( '家',$數據,真實); pdf_create($ HTML, '文件名') 或 $數據= pdf_create($ HTML, '',假); write_file('name',$ data); 我上傳Excel文件並將其覆蓋到PDF後如何放置?此功能僅適用於HTML – idan003 2014-10-10 16:31:39

+0

你好,事情首先,從Excel轉換您的數據PHP數組或數據存儲變量或數組或一類什麼的,然後使用PDF類來創建一個PDF文件,通過您從Excel中得到了數據pdf課程 – 2016-03-03 21:24:21

0

我不明白的問題。 像這樣的代碼:

$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