使用 PHPExcel 导出/导入 CSV
您能否指导我或为我提供一些使用 PHPExcel 库执行 CSV 导出和导入的示例代码?
Excel 导出和导入没问题,但我还需要 CSV 导出/导入。我有其他方式导出和导入 CSV,但也可以通过 PHPExcel 完成吗?
Could you please guide me or provide me with some sample codes for performing CSV export and import using the PHPExcel library?
Excel export and import is fine but I need CSV export/import as well. I have other means of CSV export and import, but can it be done via PHPExcel also?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将 CSV 文件导入 PHPExcel 对象
从 PHPExcel 对象导出 CSV 文件
编辑
如何读取行和单元格:
如何写入 PHPExcel 对象:
你没有说你的数据来自哪里:以下是如何通过 MySQL 查询来做到这一点
To import a CSV file into a PHPExcel object
To export a CSV file from a PHPExcel object
EDIT
How to read through the rows and cells:
How to write to a PHPExcel object:
You don't say where your data comes from: here's how to do it from a MySQL Query
我一直在寻找同样的东西。 Excel CSV 并不总是使用引号分隔符,而是使用“”转义引号,因为该算法可能是在 80 年代或其他时期制定的。在查看 PHP.NET 评论部分中的几个 .csv 解析器后,我发现有些解析器甚至使用了回调或评估代码,但它们要么无法按需要工作,要么根本无法工作。因此,我为此编写了自己的例程,它们在最基本的 PHP 配置中工作。数组键可以是数字,也可以命名为标题行中给出的字段。希望这有帮助。
...现在鲍勃可以制作他的电子表格
I been seeking the same thing. Excel CSV dosn't always use the quote separators and escapes the quotes using "" because the algorithm was probably made back the 80's or something. After looking at several .csv parsers in the comments section on PHP.NET, I seen ones that even used callbacks or eval'd code and they either didnt work like needed or simply didnt work at all. So, I wrote my own routines for this and they work in the most basic PHP configuration. The array keys can either be numeric or named as the fields given in the header row. Hope this helps.
...Now bob can do his spreadsheets