flex 读取excel文件的方法
来源:互联网 发布:devc for linux 编辑:程序博客网 时间:2024/04/29 11:22
<?xml version="1.0" encoding="utf-8"?><s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="library://ns.adobe.com/flex/spark"xmlns:mx="library://ns.adobe.com/flex/mx"><fx:Declarations><!-- Place non-visual elements (e.g., services, value objects) here --></fx:Declarations><fx:Script><![CDATA[import com.as3xls.xls.ExcelFile;import com.as3xls.xls.Sheet;import mx.collections.ArrayCollection;import mx.controls.Alert;import mx.controls.Image;import mx.core.IVisualElement;private var file:FileReference;private var xls:ExcelFile;var dp:ArrayCollection = new ArrayCollection;/*** 点击文件选择弹出框* */private function upload():void{file = new FileReference();file.addEventListener(Event.SELECT, file_select);file.addEventListener(Event.COMPLETE,file_complete);file.addEventListener(ProgressEvent.PROGRESS,file_progress);file.browse();}/*** 选择了excel之后* */private function file_select (e:Event):void {if (file.size > 0) {file.load();}}/*** excel加载完毕* */private function file_complete (e:Event):void {xls = new ExcelFile();try{xls.loadFromByteArray(e.target.data);}catch(eofe:EOFError){trace(eofe);}var sheet:Sheet = xls.sheets[0];//sheet.rowsdp = sheet.values;dp.removeItemAt(sheet.rows);dg.dataProvider = dp;}/*** 进度条控制* */private function file_progress (e:ProgressEvent):void {progressBar.label = Math.round(100 *e.bytesLoaded / e.bytesTotal) + "%";progressBar.setProgress(Math.round(100 *e.bytesLoaded / e.bytesTotal), 100);}/*** 获取表格数据* */protected function gainDgData(event:MouseEvent):void{var s:String = "";var shuju:ArrayCollection = dg.dataProvider as ArrayCollection;//行数:shuju.source.length-1 范围:0 到 shuju.source.length-2for(var i:uint = 0 ; i < shuju.source.length-1 ; i++){ //一行一行(一条记录一条记录)的遍历//每一行的列数为shuju[i]//s += shuju[i][0].value;}//var t1 = shuju.source.length;}]]></fx:Script><mx:Panel width="800" height="600" layout="vertical" title="上传示例"paddingLeft="20" paddingBottom="20" paddingRight="20"paddingTop="20"><mx:HBox><mx:ProgressBar id="progressBar" minimum="0" maximum="100"/><mx:Button label="上传导入文件" click="upload()"/></mx:HBox><mx:DataGrid id="dg"/><mx:Button label="获取表格数据" click="gainDgData(event)"/><mx:TextArea id="gainData" editable="false"/></mx:Panel></s:WindowedApplication>
0 0
- flex 读取excel文件的方法
- Flex 读取xml文件的方法:
- 读取excel文件的两个方法
- 读取excel文件的三种方法
- C# 读取excel 文件的方法
- Android应用读取Excel文件的方法
- Java读取Excel文件的方法
- 读取EXCEL文件的三种方法
- Flex读取外部XML文件的几种方法
- Flex读取XML文件的两种方法
- Flex读取XML文件的两种方法
- Flex读取XML文件的两种方法
- 文件读取方法(txt.excel)
- Java+Flex+POI 解析Excel文件(读取文件中想要的内容)
- C++读取Excel的XLS文件的方法
- c#读取excel的xls和xlsx文件的方法
- Flex读取Excel
- JAVA读取WORD,EXCEL,POWERPOINT,PDF文件的方法
- 缺失静态库bug
- 点类的实现(V1.0版)
- Spring MVC + Mybatis 整合实例
- intellij idea weblogic 下面 怎么远程断点
- 面试题:LO抽取,丢数据了怎么办?
- flex 读取excel文件的方法
- CocoaPods找不到头文件bug
- shell脚本测试 $0 $1 $2 输出文件名 参数1 参数2的值
- 我的百度网盘,资源下载地址
- oracle 查询所有 sequences
- c# equals与==的区别
- Lichee ( 四 ) 打包IMAGE
- 勾股定理
- IntelliJ IDEA 手动更新方法