Hello,I have a seemingly difficult request to tweak something minor, but perhaps someone will have an idea if this is possible.I have a function exportToExcel() that takes myFeatureLayer.graphicProvider and saves it as an Array Collection so that it can be exported to Excel as a .xls (not csv!) The featureLayer has 9 outFields set, and they show up in the Attribute Table, with the alias names as defined in my feature service, in the order as set in the outFields property.Now, when the Array Collection is populated by clicking the a button to trigger the exportToExcel() function, the export runs but the issue is my boss wants it to match how the Attribute Table looks exactly. This means, I need to figure out how to make the headers as the alias and the order of the columns needs to match. For some reason, when the Array Collection is created, the fields are arranged in alphabetical order, instead of by fields order. Is there a way to list of the column titles in order by fields? How about a way to exlude a field? (For example, the ObjectID field which does not show up in the Attribute Table, but does show up from the graphicProvider)I am thinking I will need to write some loop or conditional to grab the column title and skip over it when exporting, I'm just not sure if this is possible.Any help as always is appreciated! Thanks.DavidFor reference, here is my exportToExcel() function: private function exportToExcel():void { var featureCollection:ArrayCollection = myFeatureLayer.graphicProvider as ArrayCollection; var exportSet:Array = []; for each (var graphic:Graphic in featureCollection){ if (myMap.extent.intersects(graphic.geometry)) { exportSet.push(graphic.attributes); } } exportData = new ArrayCollection(exportSet); sheet = new Sheet(); var dataProviderCollection:ArrayCollection = ssoDataGrid.dataProvider as ArrayCollection; var rowCount:int = dataProviderCollection.length; sheet.resize(rowCount + 1,ssoDataGrid.columnCount); var columns:Array = ssoDataGrid.columns; var i:int = 0; for each (var field:DataGridColumn in columns){ fields.push(field.dataField.toString()); sheet.setCell(0,i,field.dataField.toString()); i++; } for(var r:int=0; r < rowCount; r++) { var record:Object = dataProviderCollection.getItemAt(r); /*insert record starting from row 2 else headers will be overwritten*/ insertRecordInSheet(r+1,sheet,record); } var xls:ExcelFile = new ExcelFile(); xls.sheets.addItem(sheet); var bytes: ByteArray = xls.saveToByteArray(); var fr:FileReference = new FileReference(); fr.save(bytes,"SSO_Table_Export.xls"); } private function insertRecordInSheet(row:int,sheet:Sheet,record:Object):void { var colCount:int = ssoDataGrid.columnCount; 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){ if (record[field].toString() == value) sheet.setCell(row,i,value); } i++; } } }
And how myFeatureLayer is defined: <esri:FeatureLayer id="myFeatureLayer" mode="snapshot" outFields="[ADDRESS,NEIGHBORHOOD,EST_SPILL_START_DATE,EST_SPILL_END_DATE,EST_SPILL_START_TIME,EST_SPILL_END_TIME,SPILL_VOLUME_GAL,CAUSE,CORRECTIVE_ACTION]" definitionExpression="{updateDefExp}" selectionColor="cyan" url="http://ntts10/ArcGIS/rest/services/Maps/sso_spill_type/MapServer/0"/>
This is a screenshot of the attribute table and how it needs to look in Excel:[ATTACH=CONFIG]25837[/ATTACH]This is a screenshot of how it looks when exported into Excel:[ATTACH=CONFIG]25838[/ATTACH]