Import Excel (xls) file to the ArrayCollection collection

Hi people,

I m trying to import an excel (*.xls) file to provide the data in a collection for my dataProvider arrayCollection. Therefore, I m using as3xls library and tried to apply it as in certain positions-, but it doesn´t work.

Maybe someone can give me an advice to solve the problem.

Here is my code for this part:

import

com.as3xls.xls.ExcelFile;

Import com.as3xls.xls.Sheet;

Import com.as3xls.xls.Cell;

protected var carrr:ArrayCollection;

private var loader: URLLoader;

private function xlsToArrC():void {}

CRARR =

new ArrayCollection();

     var Path: String = ".. "/ test.xls ';

     var request: URLRequest = new URLRequest (PATH);

     var loader: URLLoader = new URLLoader();

loader.dataFormat = URLLoaderDataFormat.BINARY;

loader.addEventListener (Event.COMPLETE, completeHandler);

Try

{

Loader.Load (request);

}

catch (error: error)

{

          trace ()"Unable to load URL:" ( + error); "."

}

}

private function completeHandler(event:Event):void {}

var xls:ExcelFile = new ExcelFile();

var noOfRows:int;

var noOfColumns:int;

if (data! =null & & data.length > 0) {}

xls.loadFromByteArray (loader.data);

     var : map = xls.sheets [0];

     if (map! =null) {}

noOfRows = sheet.rows;

noOfColumns = sheet.cols;

          for ()var row: int = 1; row < noOfRows; line ++) {}

               var cellKW:Cell = new Cell() ;

               var cellFZG:Cell = new Cell() ;

               var cellBT:Cell = new Cell() ;

               var cellTBT:Cell = new Cell() ;

               var cellFBT:Cell = new Cell() ;

               var valueKW:String = new String [] ;

               var valueFZG:String = new String [] ;

               var valueBT:Number = new Number();

               var valueTBT:Number = new Number();

               var valueFBT:Number = new Number();

valueKW = sheet.getCell(row,0).value;

valueFZG = sheet.getCell(row,1).value;

valueBT = sheet.getCell(row,2).value;

valueTBT = sheet.getCell(row,3).value;

valueFBT = sheet.getCell(row,4).value;

               var o: Object = {drive: bt valueFZG: valueBT, tbt:valueTBT, fbt:valueFBT, week: valueKW};

carrr.addItem (o);

}

}

}

}

flexer_student I can't see where the problem is on your code. Try this instead.

public var dataFormat:String = URLLoaderDataFormat.BINARY
public var strPath:String = "test01.xls";
public var urlLoader:URLLoader = new URLLoader();
public var urlRequest:URLRequest

/ * create loader to load the project file * /.
private function init (): void
{
urlLoader = new URLLoader();
urlLoader.dataFormat = dataFormat;
urlRequest = new URLRequest (strPath);
urlLoader.addEventListener (Event.COMPLETE, requestHandler);
urlLoader.load (urlRequest)
}
  
private void requestHandler(event:Event):void
{/ * changed here to enter the data of the current target url loader * /}
var fileData:ByteArray = event.currentTarget.data
var excelFile:ExcelFile = new ExcelFile();
var noOfRows:int;
var noOfColumns:int;
If (fileData! = null & fileData.length > 0) {}
excelFile.loadFromByteArray (fileData);
var: sheet = excelFile.sheets [0];
if(Sheet!=null)
{
noOfRows = sheet.rows;
noOfColumns = sheet.cols;
for (var row: int = 0; line)<>
{
var cellObject:Object = {};
for (var
Col: int = 0; Col<>
{
var: a cell = new Cell();
var cellValue:String = new
String [];
cell = sheet.getCell (row, col);
if(Cell!=null)
{
cellValue
= (Cell.value). ToString();
        
addProperty (cellObject, col, cellValue);
}
} / / Interior for purposes of loop
      
rebateDGDataProvider.addItem (cellObject);
rebateScheduleDG.dataProvider = rebateDGDataProvider
} //for loop ends
}
}
progressBar.visible = false;
progressBar.includeInLayout = false;
rebateScheduleDG.includeInLayout = true;
rebateScheduleDG.visible = true;
fileReference = null;
}

I'll post the complete project in a few minutes, I could not get your project to compile so I did my own and change the code to use the urlLoader class.

I remind you that this library is buggy "as3xls' for exampple does not load the sample file that you send me, I get an error that says"end of file expected. "

However, if I take the same copy of the file and glued to a pure excel sheet HERE! no problems. Also I noticed that your formatting in your worksheet. I hope that you realize that "as3xls" will remove a lot of your formatting so you better be careful in your solution.

Anywho enjoy.

If this post answered your question please brand she replied

Thank you

Miguel

Tags: Flex

Similar Questions

  • How to import an excel xls file to oracle database PL/SQL?

    Hello, im having problems to import a xls file to oracle, someone knows an easy way or a script to import this database file? THX!

    Hello

    have converted your excel to CSV, convert csv, you must save the file as option Save as fall to the bottom of the list select CSV Comma-delimited. then try

  • Export the ArrayCollection collection in XML file

    Hi all

    Is it possible to export a Flex ArrayCollection collection to an XML file.

    My collection of table is displayed in a datagrid as follows

    < mx:DataGrid = "360" x y = "120" width = "448" height = "200" dataProvider = "{questionsArr}" >
    < mx:columns >
    < mx:DataGridColumn headerText = "Issue" dataField = "issue" / >
    < mx:DataGridColumn headerText = dataField "Start" = "start" width = "40" textAlign = "center" / >
    < mx:DataGridColumn headerText = "Stop" dataField = "stop" width = "40" textAlign = "center" / >
    < / mx:columns >
    < / mx:DataGrid >

    And I want to output the XML to look like this

    < cue >
    "< question section =" "start =" "stop =" "/ >
    "< question section =" "start =" "stop =" "/ >
    "< question section =" "start =" "stop =" "/ >
    < / cue >

    Is this possible?  I mean all the data is ready, he just needs to be saved. .

    Hi djh88ukwb,

    Try something as shown below in the link by performing a loop through the arraycollection collection and forming the knots... the way you need...

    http://nsdevaraj.WordPress.com/2008/08/20/ArrayCollection-XML/

    Thank you

    Jean Claude Chari

  • When I try to import an mp3 file for the background music for my videos I get the following message: C:\Documents and Music\Karaoke.mp3 Documents\My owner could not be imported.

    Original title: Please help me

    When I try to import an mp3 file for the background music for my videos I get the following message: C:\Documents and Music\Karaoke.mp3 Documents\My owner could not be imported. The selected file is not valid or is corrupted. but before a few years, I used this then all files was import but now this errors can help u answer me please

    When I try to import an mp3 file for the background music for my videos I get the following message: C:\Documents and Music\Karaoke.mp3 Documents\My owner could not be imported. The selected file is not valid or is corrupted. but before a few years, I used this then all files was import but now this errors can help u answer me please

    =====================================
    MP3 files can be problematic in Movie Maker...
    Best bet would be to convert the files to the. WMA
    format before you import into Movie Maker.

    There are many converters available on the net... the
    the following link is an example:

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    Format Factory (freeware)
    http://www.videohelp.com/tools/Format_Factory
    (the 'direct link' is faster)
    (the file you want to download is: > FFSetup295.zip<>
    (FWIW... installation..., you can uncheck
    ('all' boxes on the last screen)
    (Windows XP / Vista / 7)

    First... after the download and installation of Format
    Factory... you can open the program and
    left click on the toolbar, the "Option" button and
    "Select an output folder to" / apply / OK.
    (this is where you find your files after they)
    are converted)

    Drag and drop your music files on the main screen...

    Select "while"WMA"/ OK...

    Click on... Beginning... in the toolbar...

    That should do it...

  • Import a wmv file to the project-first CS5.5. I got a black screen half!

    Hi, I tried to import a wmv file to the project as I do every day with the Prime Minister CS5.5. I got a black screen half! Is anyone know the reason for this?  Thank you!!!

    Looks like the same problem as this thread: http://forums.adobe.com/thread/1251905?tstart=0

  • Import a TXT file in the user dictionary

    Hi Forum,

    This is the script I m using import file txt in the "user dictionary", but the result is "undefined".

    Could someone help me how to import a Txt file in the user dictionary.

    var myUserDictionaries = app.userDictionaries;

    var myCountDict = myUserDictionaries.count ();

    myDoc var = app.activeDocument;

    myAddedWords = File("//Users/wleastudio/Desktop/AVIVA_dictionary.txt");

    for (var i = myCountDict-1; i > = 0; i--) {}

    myUserDictionary = myUserDictionaries [i];

    var myAddedWords = myUserDictionary.addedWords;

    myUserDictionary.addWord [myAddedWords];

    }

    Thank you

    Hello

    Try this example for the US English:

    var myUserDict = app.userDictionaries[21];//Should be English USA
    var txtFile = File('~/Desktop/test.txt');
    txtFile.open('r');
    wordsArray = txtFile.read().replace(/["'.,:;!?()\/\d\[\]]+/g, ' ').split(/\s+/);//cleaning the text to get only "words" mostly adapted by jongware
    txtFile.close();
    
        myUserDict.addWord(wordsArray)
    

    So long

  • How to check whether or not the arraycollection collection is initialized

    Hi all

    I am bit new to use the collection arraycollection in flex. I'm having this particular scenario, where I get Server data in a table. So I have to check if the arracollection I created is initialized or not. If it is not initialized I need to initialize it or other wise, just add collection from table to table. Here is the code snippet

    currentTrajectory = new collection ArrayCollection (event.result as Array);

    var _multiTrajectoryEvent:MultiTrajectoriesEvent;

    _multiTrajectoryEvent = new MultiTrajectoriesEvent (MultiTrajectoriesEvent.DRAW_AUTO_TRAJ);

    If (!) (_multiTrajectoryEvent.trajectories.source is nothing))

    {

    _multiTrajectoryEvent.trajectories.addItem (currentTrajectory);

    }

    else

    {

    _multiTrajectoryEvent.trajectories = new ArrayCollection ([currentTrajectory]);

    }

    But unfortunately the above code does not work for me, because the arraycollection collection is not initialized first, there is no way of checking me if it is initialized later or not as the compiler gives me the error checking to null...

    Can any Walter suggest how can I check if the table collection is initialized or not?

    I would appreciate any suggestions and thouhgts for the same

    Thank you

    Akshay

    Sorry to say, but it's not the right approach...

    I'm abt don't know what is exactly done so I'll give a generic example...

    I have an ArrayCollection collection...

    private var arrC:ArrayCollection;

    Maybe it's getting used internally in several places, so you be sure if she be initialized already or not. Then use a code something like that...

    If (arrC! = null & arrC.length > 0)

    {

    ...

    ...

    }

    If you are using

    If (arrC.Length > 0)

    {

    ...

    ...

    }

    and it is not initialised it will give exceptional at the time to compile...

    For a logic if(a && b) be true both a and b must be true, so if same first one (a) is false it will not evaluate the second logic (b).

    Thus, the previous logic works.

    concerning

    Nishant

  • get the fields of the arraycollection collection?

    I want to loop through a collection of table and access all the items (columns)

    the arrayCollection collection looks so

    .columnOne [1]
    .columnTwo [1]
    .columnThree [1]
    .columnfour [1]

    [Bindable] public var dataSet:ArrayCollection = new ArrayCollection();

    protected function application1_creationCompleteHandler(event:FlexEvent):void

    {

    TODO self-generating method stub

    var d: Array = new Array()

    var int count = 5;

    var c:Number, r: Number;

    for (var i: int = 0; i<>

    {

    c = Math.Floor (Math.Random () * 10)

    r = Math.Floor (Math.Random () * 10)

    d.push ({cost: i + 1})

    Recipes: 2 * i + 1

    });

    }

    dataSet.source = d;

    Call();

    }

    function call (): void

    {

    for each (var point: Object in dataSet)

    {

    (var key: string in point)

    {

    trace (Key)

    trace ([Key] Item)

    }

    }

    }

  • Access table in the arraycollection collection and add the item at the end of the table

    for
    
    
    "login_user":"XXX"},i);
    
    //mess2=sess_MessArr[i2];
    //mess1=dispArray[i2].fwchat_message
    
    //searchArray(mess2);}
    
    
    
    
    
    (var i:int = 0; i< dispArray.length; ++i){
    
    dispArray[i]. 
    dispArray.addItemAt({
    


    I have this code to try to access the values in the table in the arraycollection collection, but that's not it actually creates a value at the end of the arraycollection collection. can someone tell me what im doing wrong I basically want retransmits the individual tables in the arraycollection collection and add Login_user

    So, I guess your ArrayCollection collection holds an array of objects, as follows:

    public var myAC:ArrayCollection = new ArrayCollection([{first:"bob",last:"smith"},{first:"jim",last:"jones"},{first:"mary",last:"allen"}]);
    

    And you try to add a new property of login_user to each of them, right?

    for each (var obj:Object in myAC) {
         obj.login_user = obj.first + "83";
    }
    

    Each person would be firstly, properties last and login_user.  In my example above, all the login_user would set their name + number 83, so adjust you accordingly for your application.

    It is the ease (for each rock for this situation).  However, if you want to paste the iterative approach, you have published, you can try this:

    for (var i:int = 0; i < myAC.length; i++) {
         myAC.getItemAt(i).login_user = myAC.getItemAt(i).first + "83";
    }
    

    I think that the for each syntax is clearer, but anyway works the way I think you want.

  • How to get the child elements of the ArrayCollection collection?

    Hi all

    I want to analyze collection ArrayCollection and want the child node element.

    How to parse the arraycollection collection?

    for (var i: int = 0; i<>

    {if (arrayCollectionObject.getItemAt (i). Item is "requireditem")}

    your code

    break;

    }

    }

    Let me know if it helps

  • Is it possible to search the ArrayCollection collection by index?

    Hi all

    I know, we can loop and compare each element of the ArrayCollection collection to get the correct item that we want. Obveriously, performance is going to hurt and it is not a wise method of search. Can we create an index for the key field of each item? Or any other class offering such a feature?

    Thank you

    When you say "a clue" are you talking like one in a table of database index?  That is something that can speed up a search?

    I'm trying to understand your desire and I think that what I hear, is that you have an ArrayCollection collection contains a number of objects.   When you want to find a particular object, you have found a way to locate the desired instance to browse each item in the collection ArrayCollection and ask "this element is equal to the key of the object I'm looking for?   I think that you are concerned by the amount of time it can take.

    Go back decades to my knowledge of computer science, this is an o(n) algorithm where n is the number of items in the table.

    Now, if there was an 'index' (ala databases) on the data, so if this index have been sorted, you would be able to find your match in O (log n)

    You can pay an O (n log n) cost the sort index when the data structure is created, but if you have a large number of research, then it can pay for itself.

    I'm not aware of any function that will help you on this out of the box (but that doesn't mean not there does not exist, only that I don't know about it.)

    I would like to also truthly ask yourself "is it worth the cost?   How many items you will have a typical table?  How often do you locate an entry in this table?

    Neil

  • update of the arrayCollection collection

    Jin

    I have an arrayCollection collection each time it updates, I need to make some sort of a calculation, how can I do with mechanizm binding?

    Thank you
    Jean Michel

    There is an event collectionChange on the ArrayCollection collection that gets shot above power off when the ArrayCollection collection changes. You can capture this event and then sort the collection out of that.

    The reference of the language will give you a few details: http://livedocs.macromedia.com/flex/2/langref/index.html

    -Andy

  • How to upgrade the ArrayCollection collection when running?

    Am facing a problem with the arraycollection collection...
    will have an arraycolelction like that...
    var dpHierarchy:ArrayCollection = new ArrayCollection([)
    {Region: "Application1"},
    {Region: "Demand2"},
    {Region: "Demand3"},
    [{Region: "APPROVISIONNEMENTS4"}]

    now what I'm looking for is... How to upgrade this arraycollection collection during execution using actions script?
    I need to update this collection table something like this...

    var dpHierarchy:ArrayCollection = new ArrayCollection([)
    {Region: "Application1", year: '2008'},
    {Region: "demand2', year: '2008'},
    {Region: "Demand3', year: '2008'},
    [{Region: "APPROVISIONNEMENTS4", year: '2008'}]

    How to add the year field in to existing collection arraycollection as shown in the example...

    Thanks in advance
    Pratap

    Hey get...

    I have to just give

    dpHierarchy [0] ['year'] = '2008 '.

    :-)

  • Add a line of DataGrid using the ArrayCollection collection

    Work of one of these, when I hard code do it programmatically is not:

    Hard-coding approach 1 - *.
    var acData:ArrayCollection = new ArrayCollection();
    ...

    Each DataGridColum has a dataField like "col1", "col2", "col3", etc...
    Therefore, adding items like this works
    acData.addItem({col0:"testa",col1:"testb",col2:"testc",col3:"testd",col4:"teste"});)


    2 - programming approach *.
    But adding items like that does not work
    for (var j = 0; j < dataRows.length (); j ++) {}
    var t:String = [j] of dataRows m:System.NET.SocketAddress.ToString (); dataRows is of type XMLList, data are formatted as the format above
    I did a breakpoint to check and someone else watch the channel and it matches the format that works.
    acData.addItem (t);
    }

    When I try the second approach, I get all the content of the string in each cell of the grid, where, in the first approach, I get "tested" in the first column, "testb" in the second column (without quotes of course), etc...

    Anyone know why there is a difference or what I am doing wrong?

    Thanks in advance.


    I guess that's because in the second approach, you add a string to your ArrayCollection collection instead of an object as in the first approach:

    acData.addItem({col0:"testa",col1:"testb",col2:"testc",col3:"testd",col4:"teste"});) This is an object with the properties that you add to the ArrayCollection collection

    var t:String is dataRows [j] m:System.NET.SocketAddress.ToString ();. It is a string, not an object
    acData.addItem (t); you add a string to the ArrayCollection collection

    You must take your XML string and generate a new object, as in your first approach, using the End Sub

  • Import Excel to use with the PowerCLI script file

    I would try to ingest the VMware Hardening guide Excel file and then use it to run a script on some columns as column "configuration setting.

    If I can get the "Configuration parameter'"desired value""Default value"and"ID of the guideline"a powershell script, it would be easy from there.

    Someone did he do something like that or it can crack in Powershell?

    If you save the HG as XLSX file, just open the XLS and save under a XLSX in Excel, you can use the function import - Excel of Finke.

    How to install and use is described on the Github page.

    So is boils down to

    Import-Excel vSphere_6_0_Hardening_Guide_GA_15_Jun_2015.xlsx |

    Select "Configuration parameter', 'Value', 'Default value',"Orientation Id"

Maybe you are looking for