php 如何在不安装的情况下使用 PhpSpreadsheet(如 PHPExcel)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48767355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use PhpSpreadsheet without installation (like PHPExcel)
提问by MaggusK
According to the PhpSpreadsheet Docit's neccessary to install it with composer. In my case I just have a webspace without Terminal but Plesk. Is it anyway possible to use PhpSpreadsheet, like it is with PHPExcelwhere you just have to place the files in any location? What do I have to do to get it run? I found no further information how to with only FTP webserver access.
根据PhpSpreadsheet Doc,必须使用composer 安装它。就我而言,我只有一个没有终端但有 Plesk 的网络空间。难道反正可以使用PhpSpreadsheet,就像它与PHPExcel,你只需要将文件放置在任何位置?我该怎么做才能让它运行?我没有找到更多信息如何仅使用 FTP 网络服务器访问。
回答by Smartpal
In your case there are two options for you!
在您的情况下,您有两种选择!
Answer: 1
答案:1
Alternative method without terminal
没有终端的替代方法
Run composer with a PHP script in browser
Answer: 2
答案:2
Third party sites, which allow to download composer packages online. get PHPspreadsheet latest version.
第三方站点,允许在线下载 Composer 包。获取 PHPspreadsheet 最新版本。
https://php-download.com/package/phpoffice/phpspreadsheet
https://php-download.com/package/phpoffice/phpspreadsheet
BonusYou can download almost any composer packages @ https://php-download.com
奖金你可以下载几乎所有的作曲家包@ https://php-download.com
回答by FrancescoMM
Have you considered installing composer locally, running it as instructed, and then just sending the generated files to the server via normal FTP? You install composer on your computer and run it there, then upload via FTP/SFP...
您是否考虑过在本地安装composer,按照说明运行它,然后通过普通的FTP将生成的文件发送到服务器?你在你的电脑上安装 composer 并在那里运行它,然后通过 FTP/SFP 上传......
Composer is not "necessarily" intended to run live while the user is downloading the pages, it is intended to be run "mainly" on your local computer and generating the files and dependencies that later on you upload to the server. It can update the files on your server, but that is a convenience not a necessity.
Composer 并不是“必然”在用户下载页面时实时运行,而是“主要”在您的本地计算机上运行并生成稍后上传到服务器的文件和依赖项。它可以更新您服务器上的文件,但这只是一种便利,而不是必需品。
回答by lubosdz
By registering custom autoloader and PSR simplecache autoloader it is possible to fully workaround composer installation - see:
通过注册自定义自动加载器和 PSR simplecache 自动加载器,可以完全解决 composer 安装问题 - 请参阅:
https://github.com/PHPOffice/PhpSpreadsheet/issues/31#issuecomment-354502740
https://github.com/PHPOffice/PhpSpreadsheet/issues/31#issuecomment-354502740
Please note, that installation via composer is currently the only officially supported solution.
请注意,通过 composer 安装是目前唯一官方支持的解决方案。
回答by ManiaC
Smartpal, thanks for your pack, it works fine!
Smartpal,谢谢你的包,它工作正常!
Also it possible to replace folder:
也可以替换文件夹:
/phpspreadsheet/vendor/phpoffice/phpspreadsheet/src/
in Smartpal's archive with more fresh sources from phpspreadsheet github and it also will work.
在 Smartpal 的档案中,有更多来自 phpspreadsheet github 的新鲜资源,它也可以工作。
PS: If you have issues with reading xls files saved in encoding other than CP1252
, you have to seek literals CP1252
in file ./src/PhpSpreadsheet/Reader/Xls.php
and replace them with other value that you need or some named constant or even mb_detect_encoding()
. Then it will read such xls correctly.
PS:如果你有阅读保存在编码比其他的XLS文件的问题CP1252
,你不得不寻求文本CP1252
文件./src/PhpSpreadsheet/Reader/Xls.php
,并与其他价值,你需要或某些命名不变甚至取代他们mb_detect_encoding()
。然后它将正确读取此类 xls。