일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- apple push notification service (apns) is changing
- 자바스크립트비밀번호검증
- PHP 구글 OTP 인증
- html pdf 변환
- 파라미터 & 오류
- PHP 정규식 예제
- svn 충돌 해결 resolve
- bootstrap
- 구글 OTP 인증
- javascript
- group_concat 구분자
- wkhtmltopdf 실행 오류
- sha-2 root
- mariadb upgrade
- svn 충돌 해결 resolved
- httpd.conf 보안 설정
- (using password: YES)" when trying to connect
- modsecurity 설치
- mysqldump: Got error: 1045
- usb efi 시스템 파티션 삭제
- libxrender1
- 아파치 웹 서버의 정보 숨기기
- mysql root 비밀번호 변경
- bootstrap modal
- apache mod rewrite
- PHP 구글 OTP 연동
- php 배열제거
- 우분투 mysql 비밀번호 없이 로그인 될때
- 비밀번호정규식
- 비밀번호검증정규식
- Today
- Total
투덜이 개발자
php 엑셀 사용하기 본문
php 엑셀 사용하기
https://github.com/PHPOffice/PHPExcel 사이트에 접속하여 PHP Excel 라이브러리 파일을 다운 받을 수 있다.
PHPExcel 마지막 버전인 1.8.1은 2015년에 출시되었습니다. 이 프로젝트는 2017년에 공식적으로 사용이 중단되었으며 2019년에 영구적으로 보관되었습니다.
이 프로젝트는 수년 동안 유지되지 않았으며 더 이상 사용되어서는 안 됩니다. 모든 사용자는 직접 후속 PhpSpreadsheet 또는 다른 대안으로 마이그레이션해야 합니다.
PHPExcel 업데이트 진행이 안되고 있다보다 PhpSpreadsheet 권장하고 있다.
PhpSpreadsheet 공식사이트
https://phpspreadsheet.readthedocs.io/en/latest/
Welcome to PhpSpreadsheet's documentation - PhpSpreadsheet Documentation
Welcome to PhpSpreadsheet's documentation PhpSpreadsheet is a library written in pure PHP and offers a set of classes that allow you to read and write various spreadsheet file formats such as Excel and LibreOffice Calc. File formats supported Format Readin
phpspreadsheet.readthedocs.io
PhpSpreadsheet 에서는 7.4 버번 이상을 안내하고 있다.
PHP 하위 버전은 어쩔수 없이 PHPExcel 을 사용해야 할 수 있다.
또한 PhpSpreadsheet를 설치하기 위해서 PHP의 패키지 관리 소프트웨어인 composer가 설치되어 있어야 한다.
설치 방법은 공식 홈페이지에 쉽게 설명되어 있으니 참조하면 된다. https://getcomposer.org
Composer
A Dependency Manager for PHP Latest: 2.5.4 (changelog) Getting Started Download Documentation Browse Packages Issues GitHub
getcomposer.org
PHPSpreadSheet 이용하여 엑셀파일 쓰기
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$sheet->setCellValue('A2', '한글');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');
PHPSpreadSheet 이용하여 엑셀파일 읽기
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\IOFactory;
$inputFileType = 'Xlsx';
// 실제 파일
// $inputFileName = $_SERVER['DOCUMENT_ROOT']. '/회원정보.xlsx';
$inputFileName = 'hello world.xlsx';
$reader = IOFactory::createReader($inputFileType);
$spreadsheet = $reader->load($inputFileName);
$sheetData = $spreadsheet->getSheet(0)->toArray(null, true, true, true);
print_r($sheetData);
결과 :
Array ( [1] => Array ( [A] => Hello World ! ) [2] => Array ( [A] => 한글 ) )
PhpSpreadsheet 설정 샘플 코드
https://docs.3rdeyesys.com/etc/etc_phpspreadsheet_sample_code.html
PhpSpreadsheet 설정 샘플 코드
PHP로 Excel 문서 생성, 데이터 읽기를 할 수 있는 PhpSpreadsheet 설정 샘플 코드입니다
docs.3rdeyesys.com
여러가지 샘플 예제
https://github.com/PHPOffice/PhpSpreadsheet/tree/master/samples
GitHub - PHPOffice/PhpSpreadsheet: A pure PHP library for reading and writing spreadsheet files
A pure PHP library for reading and writing spreadsheet files - GitHub - PHPOffice/PhpSpreadsheet: A pure PHP library for reading and writing spreadsheet files
github.com
기타 참고
https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=lsw3210&logNo=221645761525
PhpSpreadsheet와 PHPExcel 비교
1. PHPEexcel, PhpSpreadsheet란? PHP로 엑셀을 읽거나 엑셀 파일로 저장할 수 있도록 도와주는 ...
blog.naver.com
'Program Language > PHP' 카테고리의 다른 글
CentOS php7 업그레이드 하기 (0) | 2023.03.27 |
---|---|
PHP 다중쿼리 mysqli_multi_query 트랜잭션 예제 (0) | 2023.03.08 |
[아파치설정]특정 디렉토리 PHP실행 안되게 하기 (0) | 2023.02.13 |
윈도우 아파치 서비스 2개 이상 운영하기 (1) | 2023.01.11 |
엑셀 파일 다운로드가 아닌 서버에 파일 생성하는 법... (0) | 2022.03.25 |