-2

I want to export my database to an excel file by php,I need a source code in php to do this

4

3 回答 3

0

I'm not going to write your whole program for you (that's not what this site is about) but if you have a specific problem, feel free to post another question.

It looks like PHP has a built-in function to export an array to a line in a CSV file: fputcsv. So run your query and for each row returned, call fputcsv.

Or, just use mysqldump which claims to support dumping to natively support dumping a database to CSV.

于 2010-02-02T07:20:43.290 回答
0

PLEASE NOTE!

Exporting Records to .csv is not the same as exporting records to MX Excel .csv.

First and foremost, the source code is out there. Not problem finding it.

The difference though is with Excel, with you are separating with commas and encapsulating with ", Excel escapes quotes (") with an additional quote (so it looks like "").

This means you can't simply use addslashes when trying to export.

于 2010-02-02T07:21:31.650 回答
0

这并不意味着任何伤害。如果您需要 CSV 导出的源代码(许多代码可在 php.net 获得),那么 phpBlocks 可能是适合您的工具。无需编码即可导出为 CSV。Click&Point 就像 Google 的 AppInventor。

见:http ://www.freegroup.de/software/phpBlocks/demo.html

于 2011-08-29T10:05:07.857 回答