soulvagrant/php-export-data
此软件包的最新版本(dev-master)没有可用的许可证信息。
PHP 类,用于将数据以 CSV、TSV 或 Excel XML(又称 SpreadsheeML)格式导出到文件或直接导出到浏览器
dev-master
2015-09-20 17:48 UTC
This package is not auto-updated.
Last update: 2024-09-18 18:43:48 UTC
README
由 Eli Dickinson 开发的 php-export-data
http://github.com/elidickinson/php-export-data
在宽松的 MIT 许可证下发布: https://open-source.org.cn/licenses/mit-license.php
一个简单的库,用于将表格数据导出到 Excel 适配的 XML、CSV 或 TSV。它支持将导出的数据流式传输到文件或直接作为下载传输到浏览器,因此适合导出大量数据集(您不会耗尽内存)。
Excel XML 代码基于 Oliver Schwarz 的 Excel_XML(《http://github.com/oliverschwarz/php-excel》)
如何使用它
<?php
// When executed in a browser, this script will prompt for download
// of 'test.xls' which can then be opened by Excel or OpenOffice.
require 'php-export-data.class.php';
// 'browser' tells the library to stream the data directly to the browser.
// other options are 'file' or 'string'
// 'test.xls' is the filename that the browser will use when attempting to
// save the download
$exporter = new ExportDataExcel('browser', 'test.xls');
$exporter->initialize(); // starts streaming data to web browser
// pass addRow() an array and it converts it to Excel XML format and sends
// it to the browser
$exporter->addRow(array("This", "is", "a", "test"));
$exporter->addRow(array(1, 2, 3, "123-456-7890"));
// doesn't care how many columns you give it
$exporter->addRow(array("foo"));
$exporter->finalize(); // writes the footer, flushes remaining data to browser.
exit(); // all done
?>
查看 test/ 目录以获取更多示例。
在此处列出了一些从 PHP 创建 Excel 文件的选项: http://stackoverflow.com/questions/3930975/alternative-for-php-excel/3931142#3931142