从PHP导出到Excel [英] Export from PHP to Excel

查看:92
本文介绍了从PHP导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将数据从php导出到Excel,并能够格式化excel电子表格中的各种项目。

I need to export data from php to Excel, and be able to format various items in the excel spreadsheet.

到目前为止,我发现的最好的库是 PHPExcel 。然而,它似乎很重,有点慢。有没有什么比较强大的。

So far, the best library that I have found is PHPExcel. However, it seems very heavy, and somewhat slow. Granted, it is very powerful.

有没有什么比轻量级和更快的,这让我能够导出到excel,并能够应用简单的格式化(粗体,对齐,边界)?

Is there anything a bit more lightweight and faster, that allows me to export to excel and be able to apply simple formatting (bold, alignment, borders)?

推荐答案

昨天我完成了这个工作。使用PHPExcel,我在格式化的主文档中阅读没有问题,写入20-100行内容,并保存文件(我将其保存为屏幕立即下载,而论坛上的一些人抱怨速度和开销,我正在推送大量的数据,它根本没有任何问题,做广告。

I just got done with this yesterday. Using PHPExcel, I had no problems reading in a "master" document with formatting, writing 20-100 rows of content, and saving off the file (I save it "to screen" for immediate download. While some people on the forums complained about speed and overhead, I'm pushing a lot of data its way and it doesn't have any problem at all doing what it advertises.

请注意,在某处我读到做一个串联的样式,而不是在循环中,例如,一个循环中的样式a1:a50而不是 style-> a1,style-> a2 显然,两种不同的场景有非常不同的记忆意义。

Note that somewhere I read to do styling in series as opposed to in loops when possible. For example, style a1:a50 as opposed to style->a1, style->a2 in a loop. Apparently, the two different scenarios have very different memory implications.

我发现的唯一getcha是输出和读取Excel 2003文件之间的一些怪癖,如果你完全工作在XLSX文件中,它应该与文档完全一致。

The only gotcha I found was a few quirks between outputting and reading Excel 2003 files. If you're working entirely in XLSX files, it should function exactly as documented.

这篇关于从PHP导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆