묻고답하기

XE 게시물 데이터의 일부를 정해진 형식의 엑셀 문서로 저장시키기


XE 게시판의 각 게시물의 내용과 확장변수 그리고 해당 게시물 입력날짜 와 입력한 회원의 정보중 일부분을

해당 게시물에서 ' 엑셀저장 ' 이란 버튼을 누르면 엑셀 파일로 저장할 수 있게 구현하려 합니다. 

 

이것저것 알아보다

http://phpexcel.codeplex.com 의 PHPExcel을 이용하여 엑셀 문서로의 저장이 가능하다는것을 알게되었습니다.

(이때 미리 정해진 엑셀 양식에 XE 게시판 내의 데이터들을 삽입시켜 엑셀파일로 저장하려 합니다)

 

먼저, PHPExcel을 이용하여 excel.php 란 파일을 만들었습니다. 

 

<?php
/**
 * PHPExcel
 *
 * Copyright (C) 2006 - 2011 PHPExcel
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category   PHPExcel
 * @package    PHPExcel
 * @copyright  Copyright (c) 2006 - 2011 PHPExcel (http://www.codeplex.com/PHPExcel)
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
 * @version    1.7.6, 2011-02-27
 */

/** Error reporting */
error_reporting(E_ALL);

date_default_timezone_set('Asia/Seoul');

/** PHPExcel_IOFactory */
require_once '../../../../_excel/Classes/PHPExcel.php'; 
require_once '../../../../_excel/Classes/PHPExcel/IOFactory.php';

 

$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("../../../../_excel/Tests/templates/test.xls");

 

$objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('C7', '확장변수명')
            ->setCellValue('I7', '확장변수명')
            ->setCellValue('P7', '확장변수명')
            ->setCellValue('C8', '확장변수명')
            ->setCellValue('I8', '확장변수명')
            ->setCellValue('P8', '확장변수명')


$objPHPExcel->getActiveSheet()->getStyle('E12:E21')->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->getStyle('E12:E21')->getFont()->setSize(9);

 

// Redirect output to a client¡¯s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');

 

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');

exit;

?>

 


위처럼 미리 정해진 test.xls란 엑셀화일의 양식에 맞춰 정해진 셀 위치에 확장변수내용 (실제로는 해당 게시물의 확장변수를 출력시켜야겠죠)을
입력하여 01simple.xlsx 란 파일로 저장시키는 파일인데요... 여기까지는 성공을 하였습니다.


하지만 막상 해당 XE 게시물의 데이터를 넘겨받아 하려니 여기서부터 막막 하네요.

버튼을 만들어 링크를 뿌려주면 DB의 내용을 출력을 못할테고.. 해서 보드 게시판 자체에서 처리를 하려하니 어떤식으로 수정을 해야 할지 막막하고...


board.controller.php 안의 클래스 안에 선언을 해줘야 하는건가요???


사내게시판에 꼭 필요한 사항이라 구현해야 하는데 초보 상태에서 하려니 막히네요.


조언 꼭 좀 부탁 드립니다.


 

글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
nike077 html 에서 옆으로 하게 하는 태그가 뭔가요????????? [1] 2013.08.22 by Fidelity
안드로이더스스 이상한글이 막써지내요;;  
JinkPark socialxe 서버에 api요청이 실패했습니다. [1] 2013.08.22 by 구큰타
94DT 이거 어떡해 해야 하죠 ? [2] file 2013.08.22 by 쿨럭이
한국12 •SocialXE 설치 [1] 2013.08.22 by 쿨럭이
티지로 {Document->getEditorCommponent} 값을 비우고 싶으면 어떡할까요...  
프리버즈 포인트팡팡봇 이름주기 오류.. file  
이동화309 Content 위젯에서 댓글추출할 때 New 아이콘이 안 보입니다. [3] file 2013.08.22 by 이동화309
가롸찡 게시판 스케치북5 에서 글작성 완료때 네이버광고전환페이지 설정을 하려 하는데요.. [1] 2013.08.22 by KS
구름나무바위 회원 디텍토리에 있는 reset_mail.html <- 이 파일은 어디에 사용되나요? [1] 2013.08.22 by sejin7940
Initializer rule="email' 저장 위치 [1] 2013.08.22 by sejin7940
퐁당풍당 가능한지 여부만 알려주세용 [1] 2013.08.22 by sejin7940
한국12 고수님들 도와주실거죠 file  
앙띠2 홈페이지가 갑자기 이상합니다. 도와 주세요. [2] 2013.08.22 by 수신제가
수신제가 게시판 스킨을 하나 만들고 싶은데,참조할 만한 다른 스킨은 없을까요? file  
mission 게시판 에러  
유타군 로그인이자꾸풀려요ㅜ [1] 2013.08.21 by ppointtopliz
앤드별 XE 모듈 다운이 안되네요;; [1] 2013.08.21 by 앤드별
연시랑 게시판 정렬에 관하여 질문드립니다. [2] 2013.08.21 by 연시랑
merpar 게시물 읽을 때 하단에 목록 보이지 않게 하기 [1] 2013.08.21 by sejin7940