용량 큰 엑셀 파일 처리엔 Spout
최근에 파일 용량이 큰 엑셀 파일을 읽어서 DB에 데이터를 기록하는 걸 개발했는데
용량이 크니까 PHPExcel 에서는 처리가 되지 않고 오류를...
그래서 찾아낸 Spout : https://github.com/box/spout
개발환경이 PHP 5.6.x 라서 이 버전에 사용할 수 있는 2.7.3 버전을 사용했습니다.
설치는 컴포저로 했으며 만약 컴포저 사용이 어려울 때는 아래의 require 코드를 추가해줍니다.
버전 3.x 에서는 class 명 등이 변경됐으니 그에 맞게 사용하면 됩니다.
[code]
require_once '[PATH/TO]/src/Spout/Autoloader/autoload.php';
[/code]
[code]
<?php
ini_set('memory_limit', '-1');
ini_set('max_execution_time', '0');
$file = __DIR__.'/patent.xlsx';
use Box\Spout\Reader\ReaderFactory;
use Box\Spout\Common\Type;
$reader = ReaderFactory::create(Type::XLSX);
$reader->open($file);
foreach ($reader->getSheetIterator() as $sheet) {
//if ($sheet->getIndex() > 0)
// break;
foreach ($sheet->getRowIterator() as $row) {
print_r($row);
}
}
$reader->close();
[/code]
실제 사용해본 경험으로는 11MB 정도의 엑셀 파일을 읽고 데이터를 입력하는데 10초 정도
소요되는 듯 했습니다. 물론 이 시간은 서버 환경 등에 따라 달라질 수 있습니다.
댓글 13개
좋은 정보 감사합니다.~
감사합니다.
https://opensource.box.com/spout/docs/
게시글 목록
| 번호 | 제목 |
|---|---|
| 16329 |
node.js
Node.js MongoDB 정렬
|
| 16328 |
node.js
정규 표현식으로 필터링
|
| 16327 |
node.js
환경설정 - dotenv
|
| 16326 |
node.js
Node.js MongoDB 쿼리
|
| 16325 | |
| 16324 |
node.js
nodejs MongoDB Find All
|
| 16323 |
node.js
Node.js MongoDB find
|
| 16322 |
node.js
node.js MongoDB _id Field
|
| 16321 |
node.js
node.js MongoDB 여러 문서 삽입
|
| 16320 |
node.js
Node.js MongoDB Insert
|
| 16319 |
node.js
Node.js MongoDB 컬렉션 만들기
|
| 16318 |
node.js
Node.js MongoDB 데이터베이스 생성
|
| 16317 |
node.js
Node.js MongoDB 설치
1
|
| 16316 |
node.js
Node.js 전자 메일 보내기
|
| 16315 |
node.js
Node.js 파일 업로드
|
| 16310 |
node.js
node.js 이벤트 모듈
|
| 16309 |
node.js
node.js NPM
|
| 16308 |
node.js
node.js 파일삭제, 파일 이름 바꾸기
|
| 16305 |
node.js
nodejs 기초문법 - 클래스
3
|
| 16304 |
node.js
nodejs 기초문법 - 조건문 반복문
|
| 16303 |
node.js
nodejs .기초문법 변수선언 , 함수선언
|
| 16302 |
node.js
nodejs 파일 업데이트
|
| 16301 |
node.js
nodejs 파일 만들기
|
| 16300 |
node.js
nodejs 파일 읽기
1
|
| 16299 |
node.js
Node.js 쿼리 문자열 읽기 , 쿼리 문자열 분할하기
|
| 16298 |
node.js
NOde.js HTTP 모듈
|
| 16297 |
node.js
Node.js 모듈
|
| 16295 |
node.js
nods.js 시작하기
|
| 16294 |
node.js
node.js 란 2번째
|
| 16293 |
node.js
Node.js란
1
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기