在 PHP 中生成 excel 输出的最佳方法是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10595599/
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
Which is the best way to generate excel output in PHP?
提问by Rodex
Is there any other PHP components like PHPExcel?
有没有像 PHPExcel 这样的其他 PHP 组件?
采纳答案by Sliq
There is some class that generates PHP Excel files (real excel files, not that .csv thing). I use (DEPRICATED)See edit 2:
有一些类可以生成 PHP Excel 文件(真正的 excel 文件,而不是 .csv 文件)。我使用(DEPRICATED)见编辑2:
https://github.com/PHPOffice/PHPExcel
https://github.com/PHPOffice/PHPExcel
BUT: I have had a problem when trying to read these generated excel files with the java excel READER, so there might be bugs in this PHP script.
但是:我在尝试使用 java excel READER 读取这些生成的 excel 文件时遇到了问题,因此此 PHP 脚本中可能存在错误。
EDIT: Nice one: http://www.phpclasses.org/package/2037-PHP-Generate-spreadsheet-files-Excel-xls-XML-format.html
PhpSpreadsheet is the next version of PHPExcel. It breaks compatibility to dramatically improve the code base quality (namespaces, PSR compliance, use of latest PHP language features, etc.). https://github.com/PHPOffice/PhpSpreadsheet
编辑:不错的一个:http: //www.phpclasses.org/package/2037-PHP-Generate-spreadsheet-files-Excel-xls-XML-format.html
PhpSpreadsheet 是 PHPExcel 的下一个版本。它打破了兼容性以显着提高代码库质量(命名空间、PSR 合规性、最新 PHP 语言功能的使用等)。https://github.com/PHPOffice/PhpSpreadsheet
回答by Sjoerd
Some applications generate an HTML table or a CSV file instead of a real Excel file, and pretend it is an Excel file so that Excel opens it. With HTML tables, this works surprisingly well and it even supports some formatting. With the newest Excel versions, however, you get a message asking you whether you really want to open the file.
某些应用程序生成 HTML 表或 CSV 文件而不是真正的 Excel 文件,并假装它是 Excel 文件,以便 Excel 打开它。使用 HTML 表格,这效果出奇地好,它甚至支持某些格式。但是,在最新的 Excel 版本中,您会收到一条消息,询问您是否真的要打开该文件。
回答by Miljar
There is a PHP Excel extension: http://ilia.ws/archives/222-PHP-Excel-Extension.html
有一个 PHP Excel 扩展:http: //ilia.ws/archives/222-PHP-Excel-Extension.html

