Created
August 1, 2021 08:00
-
-
Save AnatoliyAkhmatov/d5d62a9664ad0a0af5926c74d14c7ae5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require '../vendor/autoload.php'; | |
use PhpOffice\PhpSpreadsheet\Spreadsheet; | |
use PhpOffice\PhpSpreadsheet\Writer\Xlsx; | |
$cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; | |
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('../answers.xlsx'); | |
$sheet = $spreadsheet->getActiveSheet(); | |
$i = 2; | |
while(!empty(trim($sheet->getCell('A' . $i)))) { | |
$i++; | |
} | |
$data = [ | |
'test' => 'lol', | |
'mafaka' => 'beach', | |
'porno' => 'studio' | |
]; | |
$x = 0; | |
foreach($data as $key=>$value) { | |
$sheet->setCellValue($cols[$x] . $i, $value); | |
$x++; | |
} | |
$writer = new Xlsx($spreadsheet); | |
$writer->save('../answers.xlsx'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment