1. Go to this page and download the library: Download maymeow/excel-importer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
maymeow / excel-importer example snippets
use MayMeow\ExcelImporter\Models\BaseModel;
class ExampleModel extends BaseModel
{
#[\MayMeow\ExcelImporter\Attributes\Column('A')]
protected string $property;
public function getProperty()
{
return $this->property;
}
}
// ...
use MayMeow\ExcelImporter\Models\ExampleModel;
use MayMeow\ExcelImporter\Writers\ModelWriter;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
// ...
public function testImportingFile()
{
$xlsxReader = new Xlsx();
$spreadsheet = $xlsxReader->load((new TestingDataLocator())->locateExcelFile());
$writer = new ModelWriter();
/** @var array<TestingModel> $modelArray */
$modelArray = $writer->write(TestingModel::class, $spreadsheet);
}
// ...