濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > flex導(dǎo)出excel具體實(shí)現(xiàn)

flex導(dǎo)出excel具體實(shí)現(xiàn)

熱門(mén)標(biāo)簽:廣州ai外呼系統(tǒng)業(yè)務(wù) 車(chē)載電話(huà)機(jī)器人 天津企業(yè)外呼系統(tǒng)代理商 南昌crm外呼系統(tǒng)如何 外呼系統(tǒng)號(hào)碼顯示 什么行業(yè)需要電話(huà)機(jī)器人 地圖標(biāo)注多家店 無(wú)錫電銷(xiāo)外呼系統(tǒng)代理 中山外呼系統(tǒng)中間件
需要插件 as3xls-1.0.1.swc
復(fù)制代碼 代碼如下:

?xml version="1.0" encoding="utf-8"?>
s:Application 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:Script>
![CDATA[
import com.as3xls.xls.ExcelFile;
import com.as3xls.xls.Sheet;

import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.CheckBox;

[Bindable]
private var dp:Array = [
{studentID:1,name:"2ssdl",gender:"為001",birthday:"4區(qū)",className:"5清道夫卻無(wú)法"},
{studentID:2,name:"2士大",gender:"1色調(diào)",birthday:"4卻",className:"5為去去"},
{studentID:3,name:"2訪問(wèn)",gender:"1色調(diào)",birthday:"飛4",className:"訪問(wèn)5"},
{studentID:4,name:"訪問(wèn)2",gender:"0色調(diào)",birthday:"4卻",className:"為5"},
{studentID:5,name:"2各位",gender:"0色調(diào)",birthday:"4飛",className:"5為"}];

private function onCreate(dg:DataGrid):void
{
var rowCount:int = dg.dataProvider.length;
var colCount:int = dg.columnCount;
var sheet:Sheet = new Sheet();
sheet.resize(rowCount+1,colCount); //設(shè)置表格的范圍
var fields:Array = new Array();//用來(lái)保存字段
for(var i:int=0; i colCount;i++)
{
sheet.setCell(0,i,dg.columns[i].headerText.toString());//表格第0行設(shè)置字段名
fields.push(dg.columns[i].dataField.toString());
}
for(var i:int=0; i rowCount;i++)
{
var record:Object =dg.dataProvider[i];//獲取某行
insertRecordInSheet(i+1,sheet,record);
}
var excelFile:ExcelFile = new ExcelFile();//新建excel文件
excelFile.sheets.addItem(sheet);//把表格添加入excel文件中
var mbytes:ByteArray = excelFile.saveToByteArray();
var file:FileReference = new FileReference();
file.save(mbytes,"測(cè)試文件.xls"); // 定死文件名
file.addEventListener(Event.COMPLETE, function (){
Alert.show("保存成功");
});
/**回調(diào)函數(shù)**/
function insertRecordInSheet(row:int,sheet:Sheet,record:Object):void
{
for(var c:int; c colCount; c++)
{
var i:int = 0;
for each(var field:String in fields)
{
for each (var value:String in record)
{
/**循環(huán)判斷myDg列名域值record[field]與value是否相等**/
if (record[field].toString() == value)
/**寫(xiě)入表格中**/
sheet.setCell(row,i,value);
}
i++;
}
}
}
}
]]>
/fx:Script>
fx:Declarations>
!-- 將非可視元素(例如服務(wù)、值對(duì)象)放在此處 -->
/fx:Declarations>
mx:Panel>
mx:Button label="導(dǎo)出" click="onCreate(myDG)"/>
mx:DataGrid id="myDG" width="100%" rowCount="20" dataProvider="{dp}">
mx:columns>
mx:DataGridColumn headerText="學(xué)號(hào)" dataField="studentID"/>
mx:DataGridColumn headerText="姓名" dataField="name"/>
mx:DataGridColumn headerText="性別" dataField="gender" width="50"/>
mx:DataGridColumn headerText="生日" dataField="birthday" />
mx:DataGridColumn headerText="班級(jí)" dataField="className"/>
/mx:columns>
/mx:DataGrid>
/mx:Panel>
/s:Application>

標(biāo)簽:欽州 泰州 滄州 佛山 仙桃 海西 呂梁 攀枝花

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《flex導(dǎo)出excel具體實(shí)現(xiàn)》,本文關(guān)鍵詞  flex,導(dǎo)出,excel,具體,實(shí)現(xiàn),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《flex導(dǎo)出excel具體實(shí)現(xiàn)》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于flex導(dǎo)出excel具體實(shí)現(xiàn)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    汉源县| 霍邱县| 云安县| 房产| 贵阳市| 和静县| 湾仔区| 沙雅县| 外汇| 三江| 迁西县| 澄江县| 长治市| 连平县| 禄劝| 宁远县| 建湖县| 新营市| 临湘市| 那曲县| 平陆县| 崇礼县| 抚远县| 黄浦区| 阜新| 丰城市| 灵丘县| 商河县| 武乡县| 中方县| 北票市| 五台县| 封丘县| 出国| 孝感市| 新泰市| 大埔区| 军事| 凉山| 涞水县| 泽普县|