PHPackages                             kczer/excel-importer-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. kczer/excel-importer-bundle

ActiveSymfony-bundle

kczer/excel-importer-bundle
===========================

kczer/excel-importer library adjusted for Symfony framework

5.8(3y ago)0418MITPHPPHP &gt;=8.0

Since Aug 26Pushed 3y ago1 watchersCompare

[ Source](https://github.com/KrzysztofCzerwinski/ExcelImporterBundle)[ Packagist](https://packagist.org/packages/kczer/excel-importer-bundle)[ RSS](/packages/kczer-excel-importer-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (20)Used By (0)

### Table of contents

[](#table-of-contents)

- [ExcelImporterBundle](#excelimporterbundle)
    - [Installation](#installation)
    - [Documentation](#documentation)
        - [Sample import model- @ExcelColumn annotation:](#sample-import-model---excelcolumn-annotation-)
        - [Sample import - model (Technical keys):](#sample-import---model--technical-keys--)
        - [Sample import - model (Named column keys):](#sample-import---model--named-column-keys--)
        - [Sample import - display model](#sample-import---display-model)
        - [Sample import](#sample-import)
        - [Sample import - complex validation](#sample-import---complex-validation)
        - [Sample import- useful methods](#sample-import--useful-methods)
        - [Sample import- annotation validation](#sample-import--annotation-validation)
        - [Sample export](#sample-export)
        - [AbstractDictionaryExcelCell](#abstractdictionaryexcelcell)
        - [Yaml configuration](#yaml-configuration)

ExcelImporterBundle
===================

[](#excelimporterbundle)

ExcelImportedBundle enables PHP objects import from EXCEL files as well as export of the same objects.

Installation
------------

[](#installation)

You can install it with composer like so:

```
composer require kczer/excel-importer-bundle
```

Documentation
-------------

[](#documentation)

### Sample import model- @ExcelColumn annotation:

[](#sample-import-model--excelcolumn-annotation)

First, we need to create model that will represent EXCEL file content. Here we use **@ExcelColumn** annotation with following options:

- **columnKey** (Supports translate keys): can be Technical EXCEL column name (in A-ZZZ... notation) or **Named column name** (recommended) that will be value in EXCEL file. For named column names to work we need to have one row that matches all column names. Named and technical column keys must not be mixed.
- **cellName** (Supports translate keys): Name that is used for displaying error messages and also can be used for displaying straight from ExcelRow instance.
- **targetExcelCellClass**: Excel cell klas that will be used to parse excel value to property. Several of them are available out of the box:

    SyntaxDescriptionReturnedDefault validationConfigurationStringExcelCellBasic type for handling simple stringstringNonenoneIntegerExcelCellType for handling integer valuesintEXCEL value needs to be valid intnoneFloatExcelCellType for handling float valuesfloatEXCEL value needs to be numbernoneBoolExcelCellType for handling bool valuesboolValue needs to be one of \['tak', 'y', 'yes', 't', 't', 'true', '1'\] for true, or \['nie', 'n', 'no', 'false', 'f', '0'\] for false (case insensitive)true and false values are configurable, as well as option to treat empty values as false (more info in [yaml configuration](#yaml-configuration) section)DateTimeExcelCellType for handling dates or dates with timeDateTimeValue needs to be acceptable by DateTime class constructornoneAbstractDictionaryExcelCellType for handling EXCEL values that can be only in specified range (each dictionary excel cell needs to be created by extending AbstractExcelCell class)mixedValue needs to be a key from dictionary (more info in [AbstractDictionaryExcelCell](#abstractdictionaryexcelcell) section)none
- **required**: Whether the value is required in the EXCEL file (default to true)
- **options**: additional options specific for EXCEL cell. Supported options:

    EXCEL cell classoptiondescriptionDateTimeExcelCellreverseDateTimeFormatFormat used for EXCEL export of related property

### Sample import - model (Technical keys):

[](#sample-import---model-technical-keys)

Sample model for EXCEL file would look like this:

```
