전체 글에 해당하는 글 157

  1. PHPSpreadsheet 시트 추가 하기2021.11.24
반응형

PHPSpreadsheet 시트 추가 하기

Devel/그 외 ...|2021. 11. 24. 14:18
반응형
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('tab1');

에 setActiveSheetIndex 기능을 이용해서

$spreadsheet->createSheet();
// Add some data
$spreadsheet->setActiveSheetIndex(1) ->setCellValue('A1', 'Hello world!');
// Rename worksheet
$spreadsheet->getActiveSheet()->setTitle('tab2');

를 추가하면 된다.

 

총 코드

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setTitle('tab1');

$spreadsheet->createSheet();
$spreadsheet->setActiveSheetIndex(1) ->setCellValue('A1', 'Hello world!');
$spreadsheet->getActiveSheet()->setTitle('tab2');

$spreadsheet->setActiveSheetIndex(0);

 

댓글()
loading