일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- rairen
- FCM
- 설정
- jquery
- function
- html
- phpDocumentor
- API
- 옵션표
- 라이렌
- codeigniter3
- APK
- 안드로이드
- 후크
- 헬퍼
- CI3
- 코드이그나이터
- javascript
- ajax
- Database
- jw player
- php
- 함수
- 그누보드
- CodeIgniter
- 영카트
- mysql
- MSsql
- 웹 프로그래밍
- config
Archives
- Today
- Total
프로그램 개발서
[PHP] phpoffice spreadsheet 읽기 본문
파일 업로드 후 데이터 읽기
$data = $this->upload->data();
switch (str_replace('.', '', $data['file_ext'])){
case 'xls':
$inputFileType = 'Xls';
break;
case 'xlsx':
$inputFileType = 'Xlsx';
break;
case 'csv':
$inputFileType = 'Csv';
break;
default:
$inputFileType = '';
break;
}
if(isset($inputFileType) and !empty($inputFileType)){
/** Create a new Reader of the type defined in $inputFileType **/
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/** Advise the Reader that we only want to load cell data **/
$reader->setReadDataOnly(true);
/** Advise the Reader of which WorkSheets we want to load **/
$reader->setLoadSheetsOnly('Sheet1');
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = $reader->load($data['full_path']);
$sheet = $spreadsheet->getActiveSheet();
$spreadsheetData = $sheet->toArray();
// 0 번 라인은 컬럼 설명 라인이므로 제외
$insert_batch_data = array();
for($i=2; $i < count($spreadsheetData); $i++){
$lineData = $spreadsheetData[$i];
//데이터 처리 결정
}
}
반응형
'PHP' 카테고리의 다른 글
JSON 결과 나오지 않을 때 (0) | 2022.08.31 |
---|---|
usable_email : 사용가능한 이메일인지 확인 (0) | 2022.08.21 |
[PHP] DISPLAY ERROR (0) | 2021.09.02 |
[php] 코드이그나이트 config_location 시청v.1 (0) | 2021.08.24 |
[PHP][CI3] 함수 헬퍼 ver 1.5 (0) | 2021.07.08 |