从 Flex ActionScript 导出数组数据

发布于 2024-11-05 16:05:33 字数 227 浏览 2 评论 0原文

我想将保存在动作脚本数组中的数据导出为文本/CSV 文件。我搜索并发现了一些使用 datagrid 来实现 excel 导出的方法,但它们很复杂且令人困惑。我知道我必须创建一个脚本来处理这个问题,我想知道是否有这样做的例子?

我需要帮助: -在actionscript代码中调用脚本(我对此不太有经验,它可以像arrayToCVS(array)那样吗?) - 显示“下载”提示并允许用户保存 CSV,

谢谢!

I want to export the data kept in an actionscript array as a text/CSV file. I have searched and found a few that did datagrid to excel exports but they are complicated and confusing. I understand I have to create a script to handle this and I am wondering if there are examples of doing this?

I need help with:
-calling the script within actionscript code (I am not too experienced with this, can it just be something like arrayToCVS(array) ?)
-getting the "download" prompt to show up and allowing the user to save the CSV

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅黛梨妆こ 2024-11-12 16:05:33

像这样的东西应该对你有帮助。基本上它需要一个数组,创建多个标题列,并导出数组中的所有数据:

      private function exportDataGrid(arr:Array):void{
            var exportStr:String = "";
            var delimiter:String = ",";
            var fileName:String;
            fileName = "export.txt";
            exportStr += "Title" + delimiter; 
            exportStr += "Date Created" + delimiter; 
            exportStr += "Cards" + delimiter;

            exportStr += delimiter+delimiter+delimiter+"\n";

            for each(var item:Object in arr){
                exportStr += "\""+item.title+"\""+delimiter;
                exportStr += "\""+item.dateCreated+"\""+delimiter;
                exportStr += "\""+item.numCards+"\"\n";
            }
            var fileReference:FileReference = new FileReference();
            fileReference.save(exportStr, fileName);
        }

Something like this should help you. basically it takes an array, creates a number of header columns, and exports all data in the array:

      private function exportDataGrid(arr:Array):void{
            var exportStr:String = "";
            var delimiter:String = ",";
            var fileName:String;
            fileName = "export.txt";
            exportStr += "Title" + delimiter; 
            exportStr += "Date Created" + delimiter; 
            exportStr += "Cards" + delimiter;

            exportStr += delimiter+delimiter+delimiter+"\n";

            for each(var item:Object in arr){
                exportStr += "\""+item.title+"\""+delimiter;
                exportStr += "\""+item.dateCreated+"\""+delimiter;
                exportStr += "\""+item.numCards+"\"\n";
            }
            var fileReference:FileReference = new FileReference();
            fileReference.save(exportStr, fileName);
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文