承接 frvaillant/entitytoexcel 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

frvaillant/entitytoexcel

Composer 安装命令:

composer require frvaillant/entitytoexcel

包简介

Adds symfony command to export entities as excel file

README 文档

README

This package adds a command to your symfony project. You'll be able to export excel files representing your entities in order to help you to fill database with client data.
This program doesn't export any data. It just export structure of your data inb order to help you and/or your clients to give you data well formatted before import them.

Requirements

Symfony > 4.4
php > 7.0

Read before

This software is free to use, modify and share. It's made with a lot of love but comes without any guarantee.

Install

first run composer require frvaillant/entitytoexcel

Edit your config/services.yaml file and add under services key :

services:
   EntityToExcel\Command\EntityToCsvCommand:
           tags:
               - { name: 'console.command', command: 'entity:excel' }

run

launch command in your terminal :
php bin/console entity:excel Entity
Replace Entity by the name of the entity you want to export as excel file

The file is exported as Entity.xlsx in the public/xls directory

Excel file description

Each property of your entity is reported on each column of the table.
On the first line, the name of the property
On the second line, the display name (if you choose some (see below))
On the third line, the default values

Get more

The package comes with an annotation class wich allows you to be more precise
Use it with @EtEx()

  • exclude field
    If you want to exclude one of your entity properties from your excel file :
    /**
     * @EtEx(exclude=true)
     * @ORM\Column(type="string", length=255)
     */
    private $name;
  • Add a dropdown value selector
    if you want to add choices to fill cells, you can add a list parameter as below
    /**
     * @EtEx(list={"1", "0"}, defaultValue="0")
     * @ORM\Column(type="boolean")
     */
    private $isMusician;
  • Add a dropdown selector from another entity
    If your property is for example a ManyToOne Relation with another entity, you can list the values from your entity usin the listFromEntityWith argument.
    This argument needs the name of the field you want to use to list your linked entity.
     /**
     * @EtEx(listFromEntityWith="name")
     * @ORM\ManyToOne(targetEntity=Category::class, inversedBy="companies")
     * @ORM\JoinColumn(nullable=true)
     */
    private $category;
  • Default value
    You can add a default value. This value will fill the cell on the third line as an example.
    /**
     * @EtEx(defaultValue="My value")
     * @ORM\Column(type="string")
     */
    private $label;
  • display name
    By default, the title of each column is the name of the property in the entity.
    But sometimes, you'll probably want to display a translation of the terms used in entity definition.
    To do this, you can add a displayName paramater
       /**
        * @EtEx(displayName="Service maître")
        * @ORM\Column(type="array", nullable=true)
        */
       private $headService;
  • Add sheets from other entities If your entity is linked with some others. For example your entity "Person" represents some persons, and some of them are musicians.
    You probably need some more informations about musicians wich are represented by the "Musician" entity.
    With the includeFields parameter, you will generate another sheet in your excel file with the properties of the Musician entity.
    /**
     * @EtEx(includeFields=true, displayName="Precision if this person is musician")
     * @ORM\OneToOne(targetEntity=Musician::class, cascade={"persist", "remove"})
     */
    private $musicianPrecision;

You can use one of the above parameters, and of course you can use as much filters as you like

    /**
     * @EtEx(list={"0", "1", "2"}, displayName="your word", defaultValue="1")
     */

Future development

The reverse side of this program is on the way in order to import data following excel files.
To be continued ...

Feel free to report any encountered problem using issues on github
Github repository : https://github.com/frvaillant/EntityToExcel/

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固