최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday

티스토리 뷰

스프레드시트 만들기




PHPExcel 클래스


PHPExcel 클래스는 PHPExcel의 핵심입니다. 이것은 워크시트를 포함한 문서의 보안을 설정하고, 메타 데이터를 참조합니다.


PHPExcel의 단순화 개념 : 당신의 문서를 클래스로 나타낸다.


일반적으로 스프레드시트 파일에서 두가지 방법중 하나로 문서를 생성합니다. 하나는 문서를 읽어오는 것이고 


하나는 직접 작성하여 만드는 것인데


세번째 옵션으로 적게사용 되는 방법 이지만 이미 존재하는 문서를 복제하는 방법으로도 쓴다. 


보통은 앞의 두 방법중 하나를 사용한다.


파일로 부터 문서 읽기


첫번째. 파일에서 문서를 로드한다.


로드에 있어서 다른 스프레드시트 형식 지원과 사용할 수 있는 옵션들에 대해서는 PHPExcel의 사용설명서에 자세하게 설명되어 있다. 


스프레드 시트 파일의 문서를 읽기)


$inputFileName = './sampleData/example1.xls';


/** Load $inputFileName to a PHPExcel Object : PHPExcel 객체에 $inputFileName 로드 **/

$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);


문서 만들기


두번째. 새로운 문서 만들기


파일에서 로드하는 것이 아니라 새 문서를 만들기를 원할때가 있다. 그런 때에는 PHPExcel객체를 인스턴스화 해야 할 필요가 있다.


/** Create a new PHPExcel Object **/

$objPHPExcel = new PHPExcel();


새 문서는 항상 하나의 워크 시트로 작성된다.




영어원문

Creating a spreadsheet

The PHPExcel class

The PHPExcel class is the core of PHPExcel. It contains references to the contained worksheets, document security settings and document meta data.

To simplify the PHPExcel concept: the PHPExcel class represents your workbook.

Typically, you will create a workbook in one of two ways, either by loading it from a spreadsheet file, or creating it manually. A third option, though less commonly used, is cloning an existing workbook that has been created using one of the previous two methods.

Loading a Workbook from a file

Details of the different spreadsheet formats supported, and the options available to read them into a PHPExcel object are described fully in the PHPExcel User Documentation - Reading Spreadsheet Files document.

$inputFileName = './sampleData/example1.xls';

/** Load $inputFileName to a PHPExcel Object **/
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);

Creating a new workbook

If you want to create a new workbook, rather than load one from file, then you simply need to instantiate it as a new PHPExcel object.

/** Create a new PHPExcel Object **/
$objPHPExcel = new PHPExcel();

A new workbook will always be created with a single worksheet.



source : 

https://github.com/PHPOffice/PHPExcel/blob/develop/Documentation/markdown/Overview/03-Creating-a-Spreadsheet.md

댓글