<?php
// include the autoloader, so we can use PhpSpreadsheet
require_once(__DIR__ . '/vendor/autoload.php');
# Create a new Xls Reader
$reader = new PhpOfficePhpSpreadsheetReaderXlsx();
// Tell the reader to only read the data. Ignore formatting etc.
$reader->setReadDataOnly(true);
// Read the spreadsheet file.
$spreadsheet = $reader->load(__DIR__ . '/path/to/file.xlsx');
$sheet = $spreadsheet->getSheet($spreadsheet->getFirstSheetIndex());
$data = $sheet->toArray();
// output the data to the console, so you can see what there is.
die(print_r($data, true));
$spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl('https://www.example.com');
$spreadsheet->getActiveSheet()->setCellValue('E26', 'www.phpexcel.net');
$spreadsheet->getActiveSheet()->getCell('E26')->getHyperlink()->setUrl("sheet://'Sheetname'!A1");
$spreadsheet->getActiveSheet()->getProtection()->setSheet(true);
$spreadsheet->getActiveSheet()
->getStyle('A2:B2')
->getProtection()->setLocked(
Protection::PROTECTION_UNPROTECTED
);
//By sheet position index
$spreadsheet->getSheet(0)
//By sheet name
$spreadsheet->getSheetByName('Sheet 1')
php -S localhost:8000 -t vendor/phpoffice/phpspreadsheet/samples
<?php
require 'vendor/autoload.php';
use PhpOfficePhpSpreadsheetSpreadsheet;
use PhpOfficePhpSpreadsheetWriterXlsx;
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');
$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');