Skip to content

php xls 파일 읽기

디케 2009.12.07 08:23 조회 수 : 35385

php xls 파일 읽기

 


http://handreic.tistory.com/tag/php


http://nege.org/144


일단 쓰려면 몇가지를 해야 되는데, 우선 Excel 폴더로 가서 oleread.inc라는 파일을 하나 더 복사해서 OLERead.php로 바꿔준다.


혹은,


step.1
Excel/reader.php 에서

 require_once 'Spreadsheet/Excel/Reader/OLERead.php'; 를
 require_once 'oleread.inc'; 로 바꿔줌.
 경로가 틀리려서 처음에는 잘 못 된 줄 알았다.




step.2
example.php 에서

 $data->setOutputEncoding('CP1251'); 를 
 $data->setOutputEncoding('EUC-KR or CP949'); 로 바꿔줌.


이렇게 해야 한글이 정상적으로 표시된다.



여기도 읽어보면 좋을 것 같다는..ㅋ
Read and write Excel data with PHP : 
http://www-128.ibm.com/developerworks/opensource/library/os-phpexcel/#author (새 창으로 열기)

http://pear.php.net/package/Spreadsheet_Excel_Writer/redirected (새 창으로 열기)

http://www.codeplex.com/PHPExcel (새 창으로 열기)

http://sourceforge.net/projects/phpexcelreader (새 창으로 열기)


 

 

 

phpExcelReader.zip

http://sourceforge.net/projects/phpexcelreader/ 에서 Spreadsheet_Excel_Reader를 다운 받습니다.

 


<?
require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP949'); // 이부분만 바꿨습니다.
$data->read('kortest.xls');

error_reporting(E_ALL ^ E_NOTICE);
echo "<table border=1>";
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
       echo "<tr>";
       for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
              echo "<td>&nbsp;".$data->sheets[0]['cells'][$i][$j]."</td>";
       }
       echo "</tr>\n";
}
echo "</table>";
?>

 

 

 

 

 

번호 제목 글쓴이 날짜 조회 수
공지 임시파일 [1] 디케 2012.06.26 428393
» php xls 파일 읽기 file 디케 2009.12.07 35385
36 FTP 동기화 프로그램 file 디케 2012.07.18 41826
35 고스트 11.5.1.2266 file 디케 2012.07.17 45547
34 Window Manager file 디케 2012.09.15 46401
33 RichCopy Utility Spotlight IT 전문가의 업무에 필요한 고급 기능 디케 2010.03.29 47549

http://urin79.com

우린친구블로그

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소