PHP将Excel导出到特定路径? [英] PHP Export Excel to specific Path?
问题描述
可以将PHP MySQL Excel工作表导出到指定路径,例如USB闪存盘。
因为我使用php作为销售点和所有我想要的现在是一旦你点击一个按钮 - 它将收集来自MySQL数据库的记录,并将其作为excel或csv文件导出到USB闪存驱动器。
Is it possible to export a PHP MySQL Excel sheet to a specified path such as USB Flash Drive. Its because I'm using php as Point of Sale and all What i want now is once you click on a Button- it will collects records from MySQL database and exports it as excel or csv file to a USB Flash Drive.
我尝试过Google,但我似乎找不到任何东西。
I've tried to Google it out, but I can't seem to find anything.
您。
推荐答案
您需要编写文件。要写入usb驱动器,你只需要指定正确的文件路径。如果你在* nix它会像在linux或 / Volumes / USB /
的 / media / USB /
在Mac上。对于Windows,它将像 F:/
。
You need to write the file. To write to usb drive you just need to specify correct file path. If you're on *nix it would be like /media/USB/
on linux or /Volumes/USB/
on Mac. For Windows it would be like F:/
.
所以粗略的例子是
$a = array('1','2','3'); //This is imaginable row from MySQL
$f = fopen('F:/mycsv.csv', 'w');
fputcsv($f, $a);
fclose($f);
fputcsv
手册此处。
如果需要,您可以通过您的应用程序支持的任何方式向用户请求文件路径。
If needed, you can ask user for a file path in any way supported by your application.
这篇关于PHP将Excel导出到特定路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!