Flex导出CSV

阅读更多

项目中用到Flex直接导出成CSV

                var exprotStr:String;

			var ExcelStr:Array = [];

			ExcelStr.push("QuoteExchange-当前报价");

			ExcelStr.push("交易员:"+"Test");

			ExcelStr.push("保存时间:"+DateUtils.format(new Date(),'yyyy-MM-dd HH:mm:ss'));

			ExcelStr.push("");

			ExcelStr.push("剩余期限,代码,简称,Px(B),Px(O),Vol,评级,Time,状态");

			var bytes:ByteArray = new ByteArray();

			var fileReference:FileReference = new FileReference();

			if(bondDeals!=null){

				for each(var obj:Object in formatData){

					exprotStr =obj.goodsTerm+","+ obj.goodCode+","+obj.shortName+","+obj.bidPrice+","+obj.ofrPrice+","+

						obj.volume+","+obj.level+","+obj.time+","+obj.status;

					ExcelStr.push(exprotStr);

				}

				

			}

			bytes.writeMultiByte(ExcelStr.join("\r\n"),"gb2312");//中文乱码

			fileReference.save(bytes,"当前报价 "+DateUtils.format(new Date(),'yyyy-MM-dd HH-mm-ss')+".csv");

 

你可能感兴趣的:(Flex导出CSV)