CI 묻고 답하기

제목 phpexcel라이브러리 pdf 파일로 변경 에러
카테고리 CI 2, 3
글쓴이 호아세 작성시각 2017/02/20 14:45:48
댓글 : 0 추천 : 0 스크랩 : 0 조회수 : 16031   RSS

phpexcel로 excel다운로드를 만들어 놓은 코드를 tcppdf로 바꿔서 pdf다운로드를 만들려고 코드변경을 했습니다.

검색을 해보니 아래 header부분과 tcppdf 불러오는 부분을 추가하면 된다고 해서 변경해서 붙였는데

ERR_INVALID_RESPONSE 에러가 뜨고 있습니다. 어디가 잘못되었는지 모르겠습니다.  

어떤 문제때문일까요 ??? 

아래 코드 첨부합니다 .

 

 

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Excel_list extends CI_Controller
{
     public function __construct()
     {
        parent::__construct();
          
		//Call PHPExcel class
		$this->load->model('모델명');
     }


     public function 메소드명 (){

		$sDATE = $this->input->get_post('StDATE');
		$eDATE = $this->input->get_post('EndDATE');
		
		$SDATE = $data['searchsdate'];
		$EDATE = $data['searchedate'];

        $this->load->library('excel');	
​	
	    $rendererName = PHPExcel_Settings::PDF_RENDERER_TCPDF;
        $rendererLibraryPath = "/usr/share/nginx/html/test/application/third_party/phpexcel/Writer/PDF/tcpdf";
																									//PHPEXCEL 라이브러리 
        $this->excel->setActiveSheetIndex(0);
        $this->excel->getActiveSheet()->setTitle('현황');
		
		//sheet 꾸미기																					
		$this->excel->getActiveSheet()->mergeCells('A1:J1');																									//sheet 병합									 

        $this->excel->getActiveSheet()->getRowDimension("1")->setRowHeight(25);
	$this->excel->getActiveSheet()->getRowDimension("2")->setRowHeight(20);																					//열높이

        $this->excel->getActiveSheet()->getColumnDimension("A")->setWidth(25);																					//줄넓이
        $this->excel->getActiveSheet()->getColumnDimension("B")->setWidth(40);
        $this->excel->getActiveSheet()->getColumnDimension("C")->setWidth(20);
        $this->excel->getActiveSheet()->getColumnDimension("D")->setWidth(15);
        $this->excel->getActiveSheet()->getColumnDimension("E")->setWidth(15);
        $this->excel->getActiveSheet()->getColumnDimension("F")->setWidth(15);
        $this->excel->getActiveSheet()->getColumnDimension("G")->setWidth(15);
        $this->excel->getActiveSheet()->getColumnDimension("H")->setWidth(15);
        $this->excel->getActiveSheet()->getColumnDimension("I")->setWidth(15);
	$this->excel->getActiveSheet()->getColumnDimension("J")->setWidth(15);

																																								//데이터컬럼나열
		$this->excel->getActiveSheet()->setCellValue('A2', '판매13');
		$this->excel->getActiveSheet()->setCellValue('B2', '판매12');
		$this->excel->getActiveSheet()->setCellValue('C2', '판매11');
		$this->excel->getActiveSheet()->setCellValue('D2', '판매1');
		$this->excel->getActiveSheet()->setCellValue('E2', '판매2');
		$this->excel->getActiveSheet()->setCellValue('F2', '판매3');
		$this->excel->getActiveSheet()->setCellValue('G2', '판매4');
		$this->excel->getActiveSheet()->setCellValue('H2', '판매5');
		$this->excel->getActiveSheet()->setCellValue('I2', '판매6');
		$this->excel->getActiveSheet()->setCellValue('J2', '판매7');	
        
		//데이터 불러오기(기간파라미처리)
		$list = $this->list_m->productlist($SDATE, $EDATE);

		//합산을 위한 초기값설정 
		$Result_SumOpt = 0;
		$Result_PRICE = 0;
		$Result_opt1 = 0;
		$Result_opt2 = 0;
		$Result_opt3 = 0;
		$Result_a_won = 0;
		$Result_y_won = 0;
		$Result_c_won = 0;
		
		$n=3;																																					//시작되는 시트값 설정 

		//데이터값이 없을경우 처리
		if($list == "") {																																
		    
			$this->excel->getActiveSheet()->setCellValue('A3', '발권된 내역이 없습니다.');
		    $this->excel->getActiveSheet()->getStyle('B5:C6')->getBorders()->getAllBorders()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
		    $this->excel->getActiveSheet()->getRowDimension("3")->setRowHeight(50);
		    $this->excel->getActiveSheet()->getStyle('A3')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
		    $this->excel->getActiveSheet()->mergeCells('A3:J3');
		    $this->excel->getActiveSheet()->getStyle('A3:J3')->getFont()->setSize(13);
		    $this->excel->getActiveSheet()->getStyle('A3')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);


		}else{
    		
			foreach($list as $row):
    	
    																																							//합계
        		$HUMOPT = $row->1 + $row->2 + $row->3 ;
        		$HUMWON = $row->aprice + $row->yprice + $row->cprice ;
        																																						//사용상태 
      																																							//총합계	    
        	    $Result_SumOpt+= $HUMOPT;
        	    $Result_PRICE+= $HUMWON;
        	    $Result_opt1+= $row->1;
        	    $Result_opt2+= $row->2;
        	    $Result_opt3+= $row->3;
        	    $Result_a_won+= $row->aprice;
        	    $Result_y_won+= $row->yprice;
        	    $Result_c_won+= $row->cprice;
        	    
			$this->excel->getActiveSheet()->setCellValue('A'.$n, $row->c_name);	
			$this->excel->getActiveSheet()->setCellValue('B'.$n, $row->p_name);
        		$this->excel->getActiveSheet()->setCellValue('C'.$n, number_format($HUMOPT));
        		$this->excel->getActiveSheet()->setCellValue('D'.$n, number_format($HUMWON));
        		$this->excel->getActiveSheet()->setCellValue('E'.$n, number_format($row->1));
        		$this->excel->getActiveSheet()->setCellValue('F'.$n, number_format($row->2));
        		$this->excel->getActiveSheet()->setCellValue('G'.$n, number_format($row->3));
        		$this->excel->getActiveSheet()->setCellValue('H'.$n, number_format($row->aprice));
        		$this->excel->getActiveSheet()->setCellValue('I'.$n, number_format($row->yprice));
        		$this->excel->getActiveSheet()->setCellValue('J'.$n, number_format($row->cprice));
        		$this->excel->getActiveSheet()->getStyle('A'.$n.':J'.$n.'')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
        		
    		$n++;
    		endforeach;	

			$number = count($list)+3;																																//마지막sheet 구하기
               
			$this->excel->getActiveSheet()->mergeCells('A'.$number.':B'.$number.'');
			$this->excel->getActiveSheet()->setCellValue('A'.$number, '합계');
			$this->excel->getActiveSheet()->setCellValue('C'.$number, number_format($Result_SumOpt));
			$this->excel->getActiveSheet()->setCellValue('D'.$number, number_format($Result_PRICE));
			$this->excel->getActiveSheet()->setCellValue('E'.$number, number_format($Result_opt1));
			$this->excel->getActiveSheet()->setCellValue('F'.$number, number_format($Result_opt2));
			$this->excel->getActiveSheet()->setCellValue('G'.$number, number_format($Result_opt3));
			$this->excel->getActiveSheet()->setCellValue('H'.$number, number_format($Result_a_won));
			$this->excel->getActiveSheet()->setCellValue('I'.$number, number_format($Result_y_won));
			$this->excel->getActiveSheet()->setCellValue('J'.$number, number_format($Result_c_won));
        }
	
        $filename= '기준_'.date('Y.m.d.h.i.s').'.pdf'; //save our workbook as this file name
        header('Content-Type: application/pdf'); //mime type
        header('Content-Disposition: attachment;filename="'.$filename.'"'); //tell browser what's the file name
        header('Cache-Control: max-age=0'); //no cache\
		
 
        $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'PDF'); 
 
        $objWriter->save('php://output');	
	 }

}

 

 다음글 모바일사이트를 Controller와 View만 다르게 ... (2)
 이전글 ajax와 폼검증 질문 다시 드립니다ㅜsjs (5)

댓글

없음