The only error in your code is that the xlFile object is incremented each time you load a new stuff. So the sheets[0] is always the same! If your files have 3 sheets, then the first sheet of the new file is in the sheets[3] object.
To correct this try to initiate the xlFile object every time you load a new file. I have done it by me and it works perfectly! Here is my code (I have wiped some lines to simplify it)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
layout="vertical"
height="727" width="777" creationComplete="init()">
<fx:Script>
<![CDATA[
import com.as3xls.xls.ExcelFile;
import com.as3xls.xls.Sheet;
import mx.collections.ArrayCollection;
private var fileRef:FileReference;
private var ba:ByteArray;
private var xlFile:ExcelFile;
private var hdrs:Array;
private var runOnce:Boolean;
[Bindable]private var xlsheet:ArrayCollection;
private const XLS_FILTER:FileFilter = new FileFilter("EXCEL FILES (*.xls)", "*.xls");
private function init():void
{
fileRef = new FileReference();
fileRef.addEventListener(Event.SELECT, fileRef_select);
fileRef.addEventListener(ProgressEvent.PROGRESS, fileRef_progress);
fileRef.addEventListener(Event.COMPLETE, fileRef_complete);
ba = new ByteArray();
hdrs = new Array();
xlsheet = new ArrayCollection();
}
private function browseAndUpload():void {
fileRef.browse([XLS_FILTER]);
message.text = "";
}
private function fileRef_select(evt:Event):void {
try {
message.text = "size (bytes): "+ fileRef.size;
message.text += " | " + fileRef.name
fileRef.load();
} catch(err:Error) {
message.text = "ERROR: zero-byte file";
}
}
private function fileRef_progress(evt:ProgressEvent):void{
progressBar.visible = true;
}
private function fileRef_complete(evt:Event):void{
try {
xlFile = new ExcelFile();
message.text += " (complete)";
progressBar.visible = false;
ba=fileRef["data"];
xlFile.loadFromByteArray(ba);
xlsheet = xlFile.sheets[0].values;
hdrs = xlsheet[0];
xlsheet.removeItemAt(0);
grid.dataProvider = xlsheet;
} catch (err:Error) {
message.text = "An error occurred";
}
}
private function updateHeaders(): void {
if(grid.columnCount>=1){
for (var i:int=0; i<=grid.columnCount-1; i++){
grid.columns[i].headerText=hdrs[i];
}
}
}
]]>
</fx:Script>
<mx:Button label="Upload File" click="browseAndUpload();" labelPlacement="left"/>
<mx:Label id="message"/>
<mx:ProgressBar id="progressBar" indeterminate="true" visible = "false"/>
<mx:DataGrid id="grid" updateComplete="updateHeaders();"/>
</mx:Application>