묻고답하기

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 남기남
웬디 게시판에서 기능상 빼고 싶은것이 있습니다. [2] file 2008.11.16 by 띵야
잿빛늑대 XE_Official 기본에서 상단메뉴에 2차메뉴 보이는 법을 알고싶어요. (1.0.6 버전) [1] file 2008.11.16 by 느까끼
서성진856 관리자 지정 [1] 2008.11.16 by 느까끼
*이종민* 애드온에서 기본으로있는 덧글알림이??문제.. [1] 2008.11.16 by 백성찬
서버교체 서버교체를 할려고합니다.. [1] 2008.11.16 by 느까끼
goongkem 댓글알리미 애드온 사용으로 바꿨더니, 다운, 사이트연결안되요. [2] file 2008.11.16 by goongkem
pennkdesign 최근문서에 more 달기? [2] file 2008.11.16 by pennkdesign
初心不變 갤러리스킨을 naver photo 의 오늘의 포토처럼.. file  
청♡풍™ 현재 위치 출력 위젯관련 홈출력건 file  
륜슈`-♡ 오늘 처음 제로보드XE 를 접해서 설치하는과정에서 다음페이지로 넘어가지가않네요 [4] 2008.11.15 by 모두존
무무 XE 버그신고/ 아이디어 제안 스킨은 어디서 받나요? [3] 2008.11.15 by 백성찬
규혀니 게시판 상단내용 하단내용사용시에~!!! [1] file 2008.11.15 by 미눙
박노열 홈 상단으로 올리고, 검은 선 삭제하기 [2] 2008.11.15 by 박노열
박인과 게시판 접근 도움 요청 [1] 2008.11.15 by 센세이션
cosmo 파일첨부가안되요.. !! [7] 2008.11.15 by -_-
빈티지 php지원에대해서 질문좀 드릴께요 ^^;; [1] 2008.11.15 by 백성찬
lipome 태그잘하시는분께^*^ [1] 2008.11.15 by 느까끼
토이++ 좌측메뉴가 없어져요 ㅡㅡ;; [1] 2008.11.15 by 백성찬
공기정화 첨부파일 다운로드가..ㄷㄷㄷ!! [4] 2008.11.15 by 백성찬
조수정409 제로xe설치처음인데요..메뉴가좀..;; [4] 2008.11.15 by 백성찬
에디터 sandbox 4864 버젼 에디터 파일업로드..  
서성진856 플래닛(마이크로 블로그)에 대해..  
박득수 페이지 오류가 납니다 ㅜㅜ [1] 2008.11.15 by 백성찬
모냐고 아이디/비밀번호 찾기 이메일 발송에 관해서..  
박찬 가입시 메일인증  
얼쑤좋구나 .htaccess 수정으로 index 첫화면 문제 문의 [3] 2008.11.15 by 얼쑤좋구나
Chang718 1.0.6 버전 설치 때 이건 왜 그렇죠?  
시어유나 모듈이였나, 위젯 설정 중 제일 밑에 있는 메뉴의 미사용을 눌렀더니 동작을 멈춰버렸습니다. [2] 2008.11.15 by 시어유나
ZeroCalorie Style 로 박스를 그릴 때에요... ?? [2] 2008.11.15 by ZeroCalorie
천원 현재접속자 위젯에서 캐시설정 질문합니다 [2] 2008.11.15 by 천원