PHP Export Data

jopen 12年前發布 | 28K 次閱讀 PHP Office文檔處理

一個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

?></pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1343178401943

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!