如何在 Flex 中将数据网格导出到 Excel 文件?
如何将数据网格中的数据导出到 Excel 文件中/en.wikipedia.org/wiki/Adobe_Flex" rel="noreferrer">Flex?
谁能提供一些例子吗?我正在浏览,但找不到此类示例。
编辑
浏览了很多并找到了如何将datagrid数据转换为csv格式。现在如何将其转换为Excel?有没有办法在不使用任何服务器脚本的情况下做到这一点?不能单独用Flex来完成吗?
How do I export data in my datagrid to an Excel file in Flex?
Can anyone provide some examples for that? I am browsing but couldn't find out a single example of that kind.
EDIT
Browsed a lot and found out how to convert datagrid data to csv format. Now How to convert that to excel? Is there a way to do that without using any server script ? Can't it be done in Flex alone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
有 as3xls 供您写入 xls 文件。它只支持一张纸(但我认为这很好)。
但我认为,如果您不需要使用 excel 函数(如单元格公式),那么使用 @susichan 和 @Rafal Ziolkowski 所说的 csv 或 html 会更简单。
哦,还有 csvlib 用于编写 csv。对于html来说,像写XML一样就可以了。
There is as3xls for you to write xls file. It only support a single sheet(but I think that's fine).
But I think using csv or html as stated by @susichan and @Rafal Ziolkowski will be more simple if you do not need to use excel functions (like cell formula).
Oh, and there is csvlib for writing csv. For html, do it like writing XML will be fine.
如果您有 Java servlet 后端,则可以使用 servlet 来输出文件。
我唯一的 Flex 想法是输出 CSV 数据到带有文本区域的弹出窗口,用户可以将其复制并粘贴到文件中。
If you have a Java servlet back-end you can use a servlet to output the file.
My only Flex-only idea was to output the CSV data to a popup with a textarea that could be copied and pasted into a file by the user.
Excel 将 HTML 表作为一种电子表格进行读取。只需逐行、逐列读取网格并生成一组 HTML 表格单元格并生成一个名为whatever.xls 的文件。
Excel reads the HTML table as a kind of spreadsheet. Just read the grid row by row, column by column and produce a set of HTML table cells and produce a file named whatever.xls.
首先从以下链接下载 swc 文件
链接
现在您需要做一些工作,只需复制该代码并适当地给出列名称即可。
First Download swc file from the following Link
Link
Now you need to do little bit of work just copy that code and give column names appropriately.
这是您的答案
http://learnflexair.wordpress.com/category/uncategorized/air/< /a>
here is your answer
http://learnflexair.wordpress.com/category/uncategorized/air/
as3xls 看起来读起来不错,但编写 Excel 文件则是另一回事了。它无法编写多表工作簿,[大多数时候]无法读取自己的文件,当 Excel 可以读取 as3xls 输出的内容时,您必须进行多次保存才能清除所有垃圾。真是无赖。我正在使用 AIR 2.0 的 NativeProcess 调用 Python 脚本来进行编写,我想我必须先将 datagrid/ArrayCollection 导出到 CSV...似乎还有很长的路要走。不敢相信没有更好的 ActionScript 选项来处理 Excel。这任务真的有那么罕见吗?
as3xls seems to read fine but writing Excel files is another story. It can't write multisheet workbooks, it [most of the time] can't read it's own files, and when Excel can read what as3xls spits out you have to do multiple saves to get all the garbage out. A real bummer. I'm working on using AIR 2.0's NativeProcess to call a Python script to do the writing and I guess I'll have to export the datagrid/ArrayCollection to CSV first... seems like a long way around. Can't believe there's not a better ActionScript option for mucking with Excel. Is it really that rare of a task?