'; //Set the tableheader data (retrieves information from the datagrid header for(var i:int = 0;i"+dg.columns[i].headerText+""; } else { str+= ""+dg.columns[i].dataField+""; } } str += ""; colors = dg.getStyle("alternatingRowColors"); //Loop through the records in the dataprovider and //insert the column information into the table for(var j:int =0;j"; for(var k:int=0; k < dg.columns.length; k++) { //Do we still have a valid item? if(dg.dataProvider.getItemAt(j) != undefined && dg.dataProvider.getItemAt(j) != null) { //Check to see if the user specified a labelfunction which we must //use instead of the dataField if(dg.columns[k].labelFunction != undefined) { str += ""+dg.columns[k].labelFunction(dg.dataProvider.getItemAt(j),dg.columns[k].dataField)+""; } else { //Our dataprovider contains the real data //We need the column information (dataField) //to specify which key to use. str += ""+dg.dataProvider.getItemAt(j)[dg.columns[k].dataField]+""; } } } str += ""; } str+=""; return str; } /** * Load a specific datagrid into Excel * This method passes the htmltable string to an backend script which then * offers the excel download to the user. * The reason for not using a copy to clipboard and then javascript to * insert it into Excel is that this mostly will fail because of the user * setup (Webbrowser configuration). * * @params: dg Datagrid The Datagrid that will be loaded into Excel */ private function loadDGInExcel(dg:DataGrid):void { //Pass the htmltable in a variable so that it can be delivered //to the backend script var variables:URLVariables = new URLVariables(); variables.htmltable = convertDGToHTMLTable(dg); //Setup a new request and make sure that we are //sending the data through a post var u:URLRequest = new URLRequest(urlExcelExport); u.data = variables; //Pass the variables u.method = URLRequestMethod.POST; //Don't forget that we need to send as POST //Navigate to the script //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"); } ]]>