<!--
mx:Binding 태그는 해당 변수와 해당 레이블에 값을 연결할수 있다.
구지 해당 값을 변경하지 않아도 mapping이 되어 있기 때문에 변수 값을 바꾸어도 레이블에 값을 변경할수 있다.
단, 해당 변수의 [Bindable]로 선언 해주어야 된다.
-->
<mx:Binding source="caption1" destination="lab1.text" />
<mx:Binding source="caption2" destination="lab2.text" />
<!--
mx:Binding 태그를 사용하지 않아도 직접 선언할수도 있다.
<mx:Label id="lab1" x="90" y="61" text="{caption}"/>
중괄호를 사용하여 선언하면 Binding 한다는 의미가 된다.
-->
<mx:Model id="groceryInventory">
<groceries>
<catName>Dairy</catName>
<prodName>Milk</prodName>
<imageName>assets/acc.png</imageName>
<cost>1.20</cost>
<listPrice>1.99</listPrice>
<isOrganic>true</isOrganic>
<isLowFat>true</isLowFat>
<description>Direct from California where cows are happiest!</description>
</groceries>
</mx:Model>
<!--
image 태크 사용시 source를 사용하면 해당 swf에는 같이 포함이 되지 않는다.
그래서 해당 swf파일 실행시 이미지 다운로드 파일은 따로 다운로드 받는다.
그런데 swf 컴파일시 해당 이미지를 같이 컴파일 하는 방법도 있다. source에 @Embed('assets/......')로 써주면 된다.
<mx:Image source="@Embed('assets/acc.png')" />
하지만 @Embed를 사용하면 해당 이미지에 대한 크기가 swf에 같이 포함이 되기 때문에 swf가 단순 source를 사용할때보다 이미지 파일만큼 커진다.
-->
/**
* RIASolve.
* Export data, delivered in the POST, to excel.
* @author Sobhan Dutta
*/
package com.riasolve.utils
{
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
import mx.collections.IList;
import mx.collections.IViewCursor;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.navigateToURL;
public class DataGridDataExporter
{
public static function exportCSV(dg:DataGrid,
jspFile:String,
columnSeparator:String="\t",
rowSeparator:String="\n"):void
{
var data:String = "";
var columns:Array = dg.columns;
var columnCount:int = columns.length;
var column:DataGridColumn;
var header:String = "";
var headerGenerated:Boolean = false;
var dataProvider:Object = dg.dataProvider;
var rowCount:int = dataProvider.length;
var dp:Object = null;
var cursor:IViewCursor = dataProvider.createCursor ();
var j:int = 0;
header ='<table><thead>';
data = '<tr >';
//loop through rows
while (!cursor.afterLast)
{
var obj:Object = null;
obj = cursor.current;
if (headerGenerated)
data += "<tr >";
//loop through all columns for the row
for(var k:int = 0; k < columnCount; k++)
{
column = columns[k];
// Don't add if data is invisible
if(!column.visible || column.dataField==null)
{
continue;
}
data += "<td >"+ column.itemToLabel(obj)+ "</td >";
//generate header of TSV, only if it's not genereted yet
if (!headerGenerated)
{
header += "<th >" + column.headerText + "</th >";
}
}
if (!headerGenerated){
header += "</tr></thead><tbody>";
headerGenerated = true;
}
data += "</tr >";
j++;
cursor.moveNext ();
}
data += "</tbody></table >"
//set references to null:
dataProvider = null;
columns = null;
column = null;
////////////////////////////////////////////
// Start opening into a new browser
var variables:URLVariables = new URLVariables();
variables.dg = header + "\r\n" + data;
//Setup a new request and make sure that we are
//sending the data through a post
var u:URLRequest = new URLRequest(jspFile);
u.data = variables; //Pass the variables
u.method = URLRequestMethod.POST; //Don't forget that we need to send as POST
//We can use _self here, since the script will through a filedownload header
//which results in offering a download to the user (and still remaining in you Flex app.)
navigateToURL(u,"_self");
}
}
}
3: Copy this PHP or JSP file in your webapp which will open the excel file.
Math.abs(-1) // 절대값. 결과는 1
Math.sin(1) // sin 값. 결과는 0.841470984807897
Math.cos(1) // cos 값. 결과는 0.54030230586814
Math.tan(1) // tan 값. 결과는 1.5574077246549
Math.log(2) // log 값. 결과는 0.693147180559945
Math.exp(1) // 지수 값. 결과는 2.71828182845905
Math.sqrt(9) // 제곱근 값. 결과는 3
Math.pow(2 , 4) // 거듭제곱 값. 결과는 16
Math.ceil(1.1) // 가까운 정수로 올림 값. 결과는 2
Math.ceil(1.5) // 가까운 정수로 올림 값. 결과는 2
Math.floor(1.2) // 가까운 정수로 내림 값. 결과는 1
Math.floor(1.7) // 가까운 정수로 내림 값. 결과는 1
Math.round(1.2) // 가까운 정수로 반올림 값. 결과는 1
Math.round(1.5) // 가까운 정수로 반올림 값. 결과는 2
Math.max(1 , 2) // 두 정수 중 큰 정수값. 결과는 2
Math.min(1 , 2) // 두 정수 중 작은 정수값. 결과는 1
int(1.12 ); // 수치를 정수화. 결과는 1
int(1.82 ); // 수치를 정수화. 결과는 1
parseInt("3.2"); // 문자열을 정수화. 결과는 3
parseInt("3.7"); // 문자열을 정수화. 결과는 3
parseInt("5abc"); // 문자열을 정수화. 결과는 5
parseInt("abc5"); // 문자열을 정수화. 결과는 NaN
parseInt("3E8", 16); // 16 진수로 변환. 결과는 1000
parseInt("777", 8); // 8 진수로 변환. 결과는 511
parseInt("1010", 2); // 2 진수로 변환. 결과는 10
parseFloat("2") // 문자열을 부동점 숫자로 변환. 결과는 2
parseFloat("2.4") // 문자열을 부동점 숫자로 변환. 결과는 2.4
parseFloat("2.6abc") // 문자열을 부동점 숫자로 변환. 결과는 2.6
Number("11") // 문자열을 숫자로 변환. 결과는 11
Number("12.34") // 문자열을 숫자로 변환. 결과는 12.34
Number("12.34abc") // 문자열을 숫자로 변환. 결과는 NaN
sss = 123; uuu = sss.toString(); // 숫자를 문자로변환. 결과는 123
ord("abc"); // ASCII 값. 결과는 97
s = "abc"; sss = s.charCodeAt(0); // 1번째 ASCII 값 . 결과는 97
s = "abc"; sss = s.charCodeAt(1); // 2번째 ASCII 값. 결과는 98
chr(65); // ASCII 코드를 문자화. 결과는 A
String.fromCharCode(64,65,66); // ASCII 코드를 문자화. 결과는 @AB
Math.random(); // 난수 발생. 결과는 0 - 1 사이의 소숫점 포함한 값
random(5); // 난수 발생. 결과는 0,1,2,3,4 중 하나
private var imageUrl:String = "";
private var basePlusWidth = 6;
private var basePlusHeight = 26;
private function prev():void
{
var pos:int = hList.horizontalScrollPosition - 1;
var min:int = 0;
var value:int = Math.max(min, pos);
hList.horizontalScrollPosition = value;
}
private function next():void
{
var pos:int = hList.horizontalScrollPosition + 1;
var max:int = hList.maxHorizontalScrollPosition;
var value:int = Math.min(pos, max);
hList.horizontalScrollPosition = value;
}
private function slider_change(evt:SliderEvent):void
{
hList.horizontalScrollPosition = evt.value;
}
private function hListInit():void
{
var listData:Array = arr;
var baseImage:Image = new Image();
var baseImageWidth:int = 0;
var baseImageHeight:int = 0;