묻고답하기

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 남기남
rlalswnarla 처음 시작 페이지에 관하여 질문 드립니다.  
글쓴이 1.2.3으로 업그레이드 [1] 2009.06.25 by 하늘(skycheer)
징규 게시판을 자바스크립트로 불러올때 오류;; [2] 2009.06.25 by 글쓴이
김병화999 liveXE에서 티스토리 블로그는 등록이 안되나요?  
별사탕 갤러리, 웹진으로 보기 하면 에러가 나옵니다. [1] 2009.06.25 by 백성찬
푸르뫼 xe1.2.3 설치시 문제 발생 화면. [3] file 2009.06.25 by 글쓴이
하늘(skycheer) 1.2.3 업데이트 후 [4] 2009.06.25 by SMaker
글쓴이 putty관련질문 [1] 2009.06.25 by 백성찬
백종훈519 재설치 방법 문의요 [1] 2009.06.25 by narawiz
moog 제로보드로 모바일 사이트 만드는 방법? [5] 2009.06.25 by 백성찬
민트여우 업로드 에러가 맞을까요? [2] 2009.06.25 by 민트여우
글쓴이 이런문제는 대체...;; [1] file 2009.06.25 by 비나무
백종훈519 재설치 다시 문의드립니다;; [2] 2009.06.25 by 비나무
reform 오늘나올1.2.4는 그냥 덮어씌우면 되는지요 [2] 2009.06.25 by reform
글쓴이 게시글이나 답글에 스팸글이 등록되는것... file  
정숙교 제목을 입력하라는데요... ㅜㅜ [2] file 2009.06.25 by Diver
임선해 스팸글 차단혹은 삭제 ㅠ_ㅠ [2] 2009.06.25 by 나그네
유게네 zero board 게시판에 spam 이 자꾸 올라옵니다. [2] 2009.06.25 by 나그네
parkcne 계정 비번 수정방법.. [4] 2009.06.25 by 글쓴이
유형환 제 질문이 문제가 있나요?; [3] 2009.06.26 by 비나무