묻고답하기

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 남기남
서성진856 관리자 지정 [1] 2008.11.16 by 느까끼
잿빛늑대 XE_Official 기본에서 상단메뉴에 2차메뉴 보이는 법을 알고싶어요. (1.0.6 버전) [1] file 2008.11.16 by 느까끼
웬디 게시판에서 기능상 빼고 싶은것이 있습니다. [2] file 2008.11.16 by 띵야
JJonya ''크리에이티브 커먼즈 라이센스'' 사용법좀, file  
goongkem <탭방식 최근게시물> 개수 제한 어떻게 할까요? [1] 2008.11.16 by 느까끼
Hompage 레이아웃설정관련 문제요;; [2] 2008.11.16 by Hompage
김재섭462 권한이 없습니다. 페이지는 어떤것을 수정해야 가능한건가요 [2] 2008.11.16 by 이정진820
맹구 로그인한후에 세션에 IP를 기록하고 싶지않으면 어떻게하나요?  
김규현418 게시판 상단내용 하단내용...! [1] 2008.11.16 by 山水菊
trinitate 에디터 입력오류에 대한 질문입니다.  
온리타임 관리자 페이지에서 서비스형 모듈 페이지를 클릭하면 빈화면이 뜹니다. [3] 2008.11.16 by 카인682
천상세계 첨부파일 특정확장자만 안되게..  
sunny 설치시에 오류가 납니다  
이것참.. 최근 문서 출력에서 회원 본인과 관리자만 볼 수있게하려면...?  
로자 SFTP: Connection error(Socket Error#11004)가 자꾸 떠요  
엠™ 질문좀 할게요... 줄바꿈 제대로하면 화면 안뜨는 문제..  
김정훈822 하위 메뉴 내용을 상위 메뉴에서 다 볼수는 없나요? [6] 2008.11.16 by Habile
ZeroCalorie 제로보드 XE의 스킨에 대하여...??? [5] 2008.11.16 by Habile
주박사 윈도우즈 2003 서버 셋팅에 대해 [6] 2008.11.16 by 주박사
민기 통합검색창 [1] file 2008.11.16 by Xeicus