Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 150706

Re: Export offline mobile app datagrid to file able to open in Excel

$
0
0

JoJoMcGee, hope this is the example you are looking for, copy the script, paste and save the sample file just click 2x:

 

 

//dummy data

var data:Array = [];

 

 

// data header

data[0] = {a:'1º column',b:'2º column',c:'3º column'};

 

 

// data body

for(var i:int = 1; i < 100; i++)

{

          data[i] = {a:Math.random() * 100,b:Math.random() * 100,c:Math.random()};

}

 

 

//make a csv string

var csv:String = '';

for(i = 0 ; i < 100 ; i++)

{

          csv += data[i].a + ',' + data[i].b + ',' + data[i].c+'\n';

}

 

 

//write to disk

stage.doubleClickEnabled = true;

stage.addEventListener(MouseEvent.DOUBLE_CLICK,writeCSV);

 

 

function writeCSV(event:MouseEvent):void

{

    var file:FileReference = new FileReference();

    var bytes:ByteArray = new ByteArray();

    bytes.writeUTFBytes(csv);

    file.save(bytes,'test.csv');

}

 

 

Note: This script runs on AIR

 

Any questions you can ask

 

This is a library that can help you better https://code.google.com/p/csvlib/wiki/QuickStart


Viewing all articles
Browse latest Browse all 150706

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>