https://github.com/maymeow/excel-importer
⚙ Simple and extendable library for loading data from Excel files (.xlsx) into objects.
https://github.com/maymeow/excel-importer
excel excel-import excel-to-sql hacktoberfest spreadsheets xls xlsx
Last synced: 8 months ago
JSON representation
⚙ Simple and extendable library for loading data from Excel files (.xlsx) into objects.
- Host: GitHub
- URL: https://github.com/maymeow/excel-importer
- Owner: MayMeow
- License: mit
- Created: 2020-06-08T12:25:39.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-01T20:01:08.000Z (over 3 years ago)
- Last Synced: 2024-05-02T01:59:39.076Z (about 2 years ago)
- Topics: excel, excel-import, excel-to-sql, hacktoberfest, spreadsheets, xls, xlsx
- Language: PHP
- Homepage: https://themaymeow.com
- Size: 87.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# Excel importer
Simple and extendable library for loading data from Excel files (.xlsx) into objects.
This Library using `phpoffice/phpspreadsheet` to read from XLSX files. Look at their [Github](https://github.com/PHPOffice/PhpSpreadsheet)
## Read files - commandline with example data (Deprecated)
From command line with example data
```bash
php application.php app:read-file -f ./path/to/file.xlsx
```
## Via Source Code
Create new model which extending `MayMeow\ExcelImporter\Models\BaseModel`. To map column from excel to property use
`\MayMeow\ExcelImporter\Attributes\Column` attribute.
```php
property;
}
}
```
read from file following example is reading from active sheet
```php
// ...
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 $modelArray */
$modelArray = $writer->write(TestingModel::class, $spreadsheet);
}
// ...
```
## Files
For getting path to files you can create Locator by implementing `MayMeow\ExcelImporter\Tools\FileLocatorInterface` which
is not required by XLS reader but recommended.
__License MIT__