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 theincludeFieldsparameter, 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/
frvaillant/entitytoexcel 适用场景与选型建议
frvaillant/entitytoexcel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「excel」 「export」 「entity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 frvaillant/entitytoexcel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 frvaillant/entitytoexcel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 frvaillant/entitytoexcel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
The bundle for easy using json-rpc api on your project
PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
Yii2 export extension
PHP Excel Library
Bundle Symfony DaplosBundle
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-21