PHP Export Data
一个PHP类用于将数据导成CSV, TSV, 或Excel XML (aka SpreadsheeML)格式的文件或直接输出至浏览器。
<?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 ?>
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!