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

티스토리 뷰

01. Getting-Started : PHPExcel의 공식 사이트의 문서를 힘들게 번역한 것.


전제 조건, 설치, FAQ 및 링크




소프트웨어 요구사항


PHPExcel을 사용해서 개발하기 위한 요구사항은 다음과 같다.


  • PHP version 5.2.0 or newer
  • PHP extension php_zip enabled [^phpzip_footnote]
  • PHP extension php_xml enabled
  • PHP extension php_gd2 enabled (if not compiled in)


설치소개


설치는 매우 간단합니다.

 

당신의 소스파일이 있는 디렉토리가 PHPExcel의 클래스 폴더들을 복사한 위치(경로)를 참조하면 된다.


예)


  • /var/www/Classes/PHPExcel.php
  • /var/www/Classes/PHPExcel/Calculation.php
  • /var/www/Classes/PHPExcel/Cell.php


웹 서버의 루트폴더는 /var/www가 있는 경우 당신은 /var/www/에서 하위 폴더를 생성한뒤 /var/www/Classes/ 를 호출하거나


직접 해당 폴더로 파일을 복사함으로써 해결할 수 있다.



시작하기


시작하기의 좋은 방법은 다운로드에 포함된 일부 테스트들을 실행하는것이다.


"Examples"폴더를 "Classes"폴더 옆으로 복사합니다.



  • /var/www/Classes
  • /var/www/Examples/01simple.php
  • /var/www/Examples/02types.php


브라우저에서 테스트를 시작.


주의: 위에서 언급한 "Classes"폴더의 이름이 다를경우 테스트 스크립트의 시작부분의 include를 변경해야 할 필요가 있다.



유용한 링크와 도구


PHPExcel을 사용하여 개발할 때 매우 유용한 몇가지 링크와 도구가 있습니다.


아래 목록의 업데이트 버전에 대한 리스트는 PHPExcel CodePlex 페이지를 참고 하십시오.



OpenXML / SpreadsheetML


  • File format documentation : 파일 형식의 문서


     http://www.ecma-international.org/news/TC45_current_work/TC45_available_docs.htm


  • OpenXML Explained e-book : OpenXML 전자책


     http://openxmldeveloper.org/articles/1970.aspx


  • Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint 2007 File Formats :

 

    Microsoft Office 호환 워드, 엑셀용 팩, PowerPoint 2007 파일 형식

     

     http://www.microsoft.com/downloads/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en

  • OpenXML Package Explorer : OpenXML 패키지 탐색기

    

     http://www.codeplex.com/PackageExplorer/



FAQ 자주묻는 질문


최신 F.A.Q. PHPExcel 페이지는 


http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=FAQ&referringTitle=Requirements


에서 찾을 수 있습니다. 


  • 문자열 인코딩에 문제가 있는것 같다.

     PHPExcel의 모든 텍스트에 대한 UTF-8인코딩 사용이 필요하다.


    스크립트가 다른 인코딩을 사용하는 경우 PHP의 iconv()나 mb_convert_encoding()함수로 텍스트를 변환이 가능합니다.


  • PHP는 ZipArchive를 찾을 수 없는 것에 오류가 발생할 수 있다.

     특히 php_zip확장 사용이 가능하도록 설정해야 하여 모든 요구 사항을 충족해야 한다.


     Zip 압축 (Excel2007 및 OOCalc)를 사용하여 형식을 읽거나 기록 할 때 ZipArchive 클래스에만 필요합니다. 


     버전 1.7.6 이후 PCLZip 라이브러리는 ZipArchive 클래스에 대한 대안으로 PHPExcel과 함께 제공하고있다.


     호출하여 활성화 하면 다음과 같다.


     PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);


     Excel2007 쓰기 저장의 메서드를 호출하기 전에


     ZipArchive를 사용하여 되돌릴 수 있다.


     PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE);


     현재 ZipArchive(Excel2007혹은 OOCalc의 읽기)의 필요성이 없어도 Excel2007파일은 작성할 수 있다.


  • Excel2007 에서는 Windows에서 PHPExcel_Writer_2007에 의해 생성 된 파일을 열 수 없습니다.


    "엑셀에서 읽을 수 없는 콘텐츠 확장자인 '.xlsx'를 찾으면 이 통합 문서의 내용을 복구 하시겠습니까? 가 뜨고 


    이 통합 문서의 원본을 신뢰할 수 있으면 를 클릭합니다."


    5.2.x php_zip 확장의 일부 이전버전에서는 Windows에서 ZIP파일을 만들때 오류를 포함하고 있다.


    그래서 http://snaps.php.net/win32/php5.2-win32-latest.zip 버전의 경우 항상 올바르게 작동하며


    적어도 PHP 5.2.9로 업그레이드하면 문제가 해결된다.


    만약 당신이 ZipArchive의 깨끗한 사본을 찾을 수 없는 경우 상술 한 바와 같이, Excel2007파일을 기록 할 때, 

    

    대안으로 PCLZip 라이브러리를 사용할 수 있다.



  • 치명적인 오류 : Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa

                           허용된 메모리 사이즈 xxx bytes를 다 소모하였다.

PHPExcel은 스프레드시트에 대해 "in memory" 표현으로 보유하기 때문에 PHP의 메모리 제한을 받기 쉽다.


PHP가 사용할 메모리는 php.ini파일에서 memory_limit의 값을 편집하여 증가 시킬 수 있다.


또는 ini_set('memory_limit', '128M')를 사용하고 코드 내에서(ISP 허용)을 포함하여 해결할 수 있다.


일부 읽기와 쓰기는 다른 사람보다 더 빠를수 있으며, 그들은 또한 서로 다른 양의 메모리를 사용 할 수도 있습니다.


당신은 읽기와 쓰기에 대한 상대적 성능과 메모리사용의 몇가지 징후를 찾을 수 있는데, 관련된 토론 게시판의 주소는 


http://phpexcel.codeplex.com/discussions/234150 입니다.


이미 최대 메모리에 도달했거나, 메모리 제한을 변경할 수없는 경우, 다음 이 토론 보드는 PHPExcel를 사용하여 스크립트의 메모리 


사용량을 줄이기 위해 적용 할 수 있는 몇 가지 방법에 대해 설명합니다.


  • 워크 시트에 대한 보호가 작동하지 않습니다?

워크 시트 보호 기능 중 하나 (예를 들어 셀 범위 보호, 행 삭제 금지, ...)를 사용 할 때, 당신은 워크 시트 보안을 활성화해야합니다. 


예를 들어 다음과 같이 수행 할 수있습니다.


$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);


  • 기능 X가 PHPExcel_Reader_Y / PHPExcel_Writer_Z 작동하지 않습니다.

모든 기능이 PHPExcel에 구현되어있지는 않습니다.


이것은 기본 라이브러리에 주로 기인하고있고 특정 기능을 구현하는것은 포함하고 있지 않다.


예를 들어 자동 필터는 우리의 Excel5 쓰기 기반의 PEAR Spreadsheet_Excel_writer에 구현되어 있지않다.


우리는 천천히 /Documentation폴더에 있는 "Functionality Cross-Reference.xls"과 함께 읽기와 쓰기를 지원하는 다른 목록을 


구축하고 있다.


  • Excel2003에서 수식 계산에 대한 호환 기능팩을 사용할 수 없습니까?

이 호환 기능 팩의 정상적인 동작입니다, Excel2007가 올바르게 표시됩니다. 


당신이 정말로 계산된 값 혹은 Excel2003에 대한 강제 재 계산을 해야 하는 경우 PHPExcel_Writer_Excel5를 사용합니다.


  • 열 너비를 설정하면 100% 정확하지 않습니다

열 너비를 설정하려고 하니 하나의 문제가 발생합니다. 


나는 Excel에서 파일을 열었을 때, 실제 폭은 0.71 이하이다.


간단한 대답은 PHPExcel이 패딩이 포함된 측정 값을 사용한다는 것입니다.


자세한 내용은 "열의 폭을 설정 Setting a column's width" 절을 참조하십시오.



  • 어떻게 PHPExcel 프레임 워크를 사용합니까

PHPExcel과 Joomla에 대한 몇가지 지침이 Joomla message board에 있습니다.


PHPExcel 사용에 대한 몇 가지 지침이 있습니다 Joomla의 메시지 보드.

http://www.http.com/forum.joomla.org/viewtopic.php?f=304&t=433060


YII프레임워크에서 PHPExcel을 사용하는 방법에 대한 조언 페이지.

http://www.yiiframework.com/wiki/101/how-to-use-phpexcel-external-library-with-yii/


PHPExcel을 읽고 쓰기위한 CakePHP가 포함된 The Bakery에 대한 내용.

http://bakery.cakephp.org/articles/melgior/2010/01/26/simple-excel-spreadsheet-


PHPExcel into Kohana3와 Kohana Framework가 통합된 내용

http://www.flynsarmy.com/2010/07/phpexcel-module-for-kohana-3/

http://szpargalki.blogspot.kr/2011/02/phpexcel-kohana-framework.html


PHPExcel with Typo3에서 사용하는 방법

http://typo3.org/documentation/document-library/extension-manuals/phpexcel_library/1.1.1/view/toc/0/



  • Joomla의 Autoloader는 PHPExcel Autoloader를 방해합니다.

peterrlynch덕분에 문제 해결에 대한 다음과 같은 조언을 얻을 수 있습니다.


http://phpexcel.codeplex.com/discussions/211925



자습서


영어 PHPExcel 튜토리얼 

http://openxmldeveloper.org


프랑스어 PHPExcel 튜토리얼 

http://g-ernaelsten.developpez.com/tutoriels/excel2007/


러시아어 PHPExcel 블로그 게시물 

http://www.web-junior.net/sozdanie-excel-fajjlov-s-pomoshhyu-phpexcel/


PHPExcel에 일본어 소개 

http://journal.mycom.co.jp/articles/2009/03/06/phpexcel/index.html


[^ phpzip_footnote] : php_zip은 단지 PHPExcel_Reader_Excel2007, PHPExcel_Writer_Excel2007 그리고 


                              PHPExcel_Reader_OOCalc에서 필요합니다.


즉, PHPExcel에서 .xlsx혹은 .ods파일을 필요로 하는 경우에 zip의 확장이 필요합니다. 그러나 필요가 없으면 그렇지 않아도 됩니다.


당신은 PHPExcel과 함께 번들로 제공되는 PCLZip라이브러리를 사용하여(아직 읽기는 불가) Excel2007파일을 작성하는 동안 


이 종속성(의존성)을 제거 할 수 있습니다.


이에 대한 자세한 내용은 이 문서의 FAQ섹션을 참조하십시오.


PCLZip은 PHP의 ZLIB 확장이 활성화되고 그에 따른 종속성(의존성)을 가지고 있다.  




영어원문)


Prerequisites, Installation, FAQ and Links

Software requirements

The following software is required to develop using PHPExcel:

  • PHP version 5.2.0 or newer
  • PHP extension php_zip enabled [^phpzip_footnote]
  • PHP extension php_xml enabled
  • PHP extension php_gd2 enabled (if not compiled in)

Installation instructions

Installation is quite easy: copy the contents of the Classes folder to any location within your application source directories.

Example:

If your web root folder is /var/www/ you may want to create a subfolder called /var/www/Classes/ and copy the files into that folder so you end up with files:

/var/www/Classes/PHPExcel.php
/var/www/Classes/PHPExcel/Calculation.php
/var/www/Classes/PHPExcel/Cell.php
...

Getting started

A good way to get started is to run some of the tests included in the download.
Copy the "Examples" folder next to your "Classes" folder from above so you end up with:

/var/www/Examples/01simple.php
/var/www/Examples/02types.php
...

Start running the tests by pointing your browser to the test scripts:

http://example.com/Tests/01simple.php
http://example.com/Tests/02types.php
...

Note: It may be necessary to modify the include/require statements at the beginning of each of the test scripts if your "Classes" folder from above is named differently.

Useful links and tools

There are some links and tools which are very useful when developing using PHPExcel. Please refer to the PHPExcel CodePlex pages for an update version of the list below.

OpenXML / SpreadsheetML

Frequently asked questions

The up-to-date F.A.Q. page for PHPExcel can be found on http://www.codeplex.com/PHPExcel/Wiki/View.aspx?title=FAQ&referringTitle=Requirements.

There seems to be a problem with character encoding...

It is necessary to use UTF-8 encoding for all texts in PHPExcel. If the script uses different encoding then you can convert those texts with PHP's iconv() or mb_convert_encoding() functions.

PHP complains about ZipArchive not being found

Make sure you meet all requirements, especially php_zip extension should be enabled.

The ZipArchive class is only required when reading or writing formats that use Zip compression (Excel2007 and OOCalc). Since version 1.7.6 the PCLZip library has been bundled with PHPExcel as an alternative to the ZipArchive class.

This can be enabled by calling:

PHPExcel_Settings::setZipClass(PHPExcel_Settings::PCLZIP);

before calling the save method of the Excel2007 Writer.

You can revert to using ZipArchive by calling:

PHPExcel_Settings::setZipClass(PHPExcel_Settings::ZIPARCHIVE);

At present, this only allows you to write Excel2007 files without the need for ZipArchive (not to read Excel2007 or OOCalc)

Excel 2007 cannot open the file generated by PHPExcel_Writer_2007 on Windows

"Excel found unreadable content in '.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes."*

Some older versions of the 5.2.x php_zip extension on Windows contain an error when creating ZIP files. The version that can be found on http://snaps.php.net/win32/php5.2-win32-latest.zip should work at all times.

Alternatively, upgrading to at least PHP 5.2.9 should solve the problem.

If you can't locate a clean copy of ZipArchive, then you can use the PCLZip library as an alternative when writing Excel2007 files, as described above.

Fatal error: Allowed memory size of xxx bytes exhausted (tried to allocate yyy bytes) in zzz on line aaa

PHPExcel holds an "in memory" representation of a spreadsheet, so it is susceptible to PHP's memory limitations. The memory made available to PHP can be increased by editing the value of the memory_limit directive in your php.ini file, or by using ini_set('memory_limit', '128M') within your code (ISP permitting).

Some Readers and Writers are faster than others, and they also use differing amounts of memory. You can find some indication of the relative performance and memory usage for the different Readers and Writers, over the different versions of PHPExcel, on the discussion board.

If you've already increased memory to a maximum, or can't change your memory limit, then this discussion on the board describes some of the methods that can be applied to reduce the memory usage of your scripts using PHPExcel.

Protection on my worksheet is not working?

When you make use of any of the worksheet protection features (e.g. cell range protection, prohibiting deleting rows, ...), make sure you enable worksheet security. This can for example be done like this:

$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true);
Feature X is not working with PHPExcel_Reader_Y / PHPExcel_Writer_Z

Not all features of PHPExcel are implemented in all of the Reader / Writer classes. This is mostly due to underlying libraries not supporting a specific feature or not having implemented a specific feature.

For example autofilter is not implemented in PEAR Spreadsheet_Excel_writer, which is the base of our Excel5 writer.

We are slowly building up a list of features, together with the different readers and writers that support them, in the "Functionality Cross-Reference.xls" file in the /Documentation folder.

Formulas don't seem to be calculated in Excel2003 using compatibility pack?

This is normal behaviour of the compatibility pack, Excel2007 displays this correctly. Use PHPExcel_Writer_Excel5 if you really need calculated values, or force recalculation in Excel2003.

Setting column width is not 100% accurate

Trying to set column width, I experience one problem. When I open the file in Excel, the actual width is 0.71 less than it should be.

The short answer is that PHPExcel uses a measure where padding is included. See section: "Setting a column's width" for more details.

How do I use PHPExcel with my framework
Joomla Autoloader interferes with PHPExcel Autoloader

Thanks to peterrlynch for the following advice on resolving issues between the PHPExcel autoloader and Joomla Autoloader

Tutorials

[^phpzip_footnote]: php_zip is only needed by PHPExcel_Reader_Excel2007, PHPExcel_Writer_Excel2007 and PHPExcel_Reader_OOCalc. In other words, if you need PHPExcel to handle .xlsx or .ods files you will need the zip extension, but otherwise not.
You can remove this dependency for writing Excel2007 files (though not yet for reading) by using the PCLZip library that is bundled with PHPExcel. See the FAQ section of this document for details about this. PCLZip does have a dependency on PHP's zlib extension being enabled.


source : https://github.com/PHPOffice/PHPExcel/blob/develop/Documentation/markdown/Overview/01-Getting-Started.md

댓글