如何安装maatwebsite/excel?

背景

项目要下载内容,那最好是用扩展了,常用的也就是maatwebsite/excel,但是今天安装的提示异常

错误如下:

  Problem 1
    - maatwebsite/excel[3.1.28, ..., 3.1.30] require phpoffice/phpspreadsheet 1.16.* -> satisfiable by phpoffice/phpspreadsheet[1.16.0].
    - maatwebsite/excel[3.1.31, ..., 3.1.x-dev] require phpoffice/phpspreadsheet ^1.18 -> satisfiable by phpoffice/phpspreadsheet[1.18.0, ..., 1.29.0].
    - maatwebsite/excel 3.1.27 requires phpoffice/phpspreadsheet ^1.16 -> satisfiable by phpoffice/phpspreadsheet[1.16.0, ..., 1.29.0].
    - maatwebsite/excel 3.1.26 requires phpoffice/phpspreadsheet ^1.15 -> satisfiable by phpoffice/phpspreadsheet[1.15.0, ..., 1.29.0].
    - maatwebsite/excel[3.1.22, ..., 3.1.25] require phpoffice/phpspreadsheet ^1.14 -> satisfiable by phpoffice/phpspreadsheet[1.14.0, ..., 1.29.0].
    - phpoffice/phpspreadsheet[1.14.0, ..., 1.28.0] require maennchen/zipstream-php ^2.1 -> satisfiable by maennchen/zipstream-php[2.1.0, ..., v2.x-dev].
    - phpoffice/phpspreadsheet 1.29.0 requires maennchen/zipstream-php ^2.1 || ^3.0 -> satisfiable by maennchen/zipstream-php[2.1.0, ..., v2.x-dev, 3.0.0-beta.1, ..., 3.1.0].
    - maatwebsite/excel 3.1.0 requires illuminate/support ^5.5 -> found illuminate/support[v5.5.0, ..., 5.8.x-dev] but these were not loaded, likely because it conflicts with another require.
    - maatwebsite/excel[3.1.1, ..., 3.1.6] require illuminate/support 5.5.* || 5.6.* || 5.7.* -> found illuminate/support[v5.5.0, ..., 5.7.x-dev] but these were not loaded, likely because it conflicts with another require.
    - maatwebsite/excel[3.1.7, ..., 3.1.15] require illuminate/support 5.5.*|5.6.*|5.7.*|5.8.* -> found illuminate/support[v5.5.0, ..., 5.8.x-dev] but these were not loaded, likely because it conflicts with another require.
    - maatwebsite/excel[3.1.16, ..., 3.1.18] require illuminate/support 5.5.*|5.6.*|5.7.*|5.8.*|^6.0 -> found illuminate/support[v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev] but these were not loaded, likely because it conflicts with another require.
    - maatwebsite/excel[3.1.19, ..., 3.1.21] require illuminate/support 5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0 -> found illuminate/support[v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev] but these were not loaded, likely because it conflicts with another require.
    - maennchen/zipstream-php[2.2.0, ..., v2.x-dev] require php ^8.0 -> your php version (7.4.14) does not satisfy that requirement.
    - maennchen/zipstream-php[2.1.0, ..., 2.2.6] require psr/http-message ^1.0 -> found psr/http-message[1.0, 1.0.1, 1.1] but the package is fixed to 2.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - maennchen/zipstream-php[3.0.0-beta.1, ..., 3.1.0] require php-64bit ^8.1 -> your php-64bit version (7.4.14) does not satisfy that requirement.
    - Root composer.json requires maatwebsite/excel ^3.1 -> satisfiable by maatwebsite/excel[3.1.0, ..., 3.1.x-dev].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

解决之路

看到报错,错误的发生是因为composer无法加载phpoffice/phpspreadsheet包。正常情况下,composer能够安装依赖项,现手动试试让它安装的时候自动安装依赖项,

composer require maatwebsite/excel --update-with-dependencies

然后就正常了哈

导出excel时单元格内换行的问题,请点击这里查看

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值