Load a file into ByteArray

Hi all

First of all, I would like to thank everyone on this forum. You may not know it, but you helped me get up now with my request.

Forgive my stupidity, as I'm a noob with ActionScript. But what I try to do is to read an excel file that I have stored in my src file. Its called "t1.xls".

I use a library called as3xls and this is what my code looks like:

var xls:ExcelFile = new ExcelFile();
var ba:ByteArray = new ByteArray();

var f:File = File.applicationDirectory;
f = f.resolvePath("t1.xls");

ba = tempFiles.data;
xls.loadFromByteArray(ba);

ExcelFile class is a class that comes with the as3xls library.

I get an error when you do this, which is basically telling me that my ByteArray is null. I don't know much, but I suspect that I do not read the file correctly. As I said earlier, the file, "t1.xls" is located in my src folder.

I would like to know if I'm reading the file correctly, and if I do something wrong, how do I make a ByteArray from a file in my src file.

Thanks in advance

Hello

You must first load the file until you can access the ByteArray of this file data.

Here's a simple example:

private function onClick(e:Event):void {
    loadStatus = "Loading file";

    _xlsFile = File.applicationDirectory.resolvePath('sample.xls');
    _xlsFile.addEventListener(Event.COMPLETE, onFileLoaded);
    _xlsFile.load();
}

protected function onFileLoaded(event:Event):void
{
    var ef:ExcelFile = new ExcelFile();
    ef.loadFromByteArray(_xlsFile.data);
    loadStatus = "Loaded sheets: " + ef.sheets.length;
}

You should also know that as3xls is using the Flex framework classes then you will not be able to use this library in your project in pure AS3/QNX.

Here is the example of Flex Hero project where you can see the complete example.

You will need Flash Builder Burrito to open the project.

Tags: BlackBerry Developers

Similar Questions

  • Loading a file into a global variable problem - really a global var text?

    Of all the documentation and the examples that I can find, it seems that it would be

    fix to create a global table [outside any function] variable to load image names

    then use these images to a slide show. I want to do the dynamic application, modify the text file as a new series of images.

    The global variable passes zero [any value] after the load event listener. Why is this?

    Is not global and world alive for the duration of the SWF?

    PARAMS. TXT:

    monthNames = January, February, March, April, may, June, July, August, September, October, November, December of & dayNames = Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

    CODE:

    var dNames:Array = new Array();
    var mNames:Array = new Array();
    var request: URLRequest = new URLRequest("images/params.txt");
    variable var: URLLoader = new URLLoader();
    variables.dataFormat = pouvez;
    variables.addEventListener (Event.COMPLETE, completeHandler);
    Try
    {
    variables. Load (request);
    }
    catch (error: error)
    {
    trace ("unable to load URL:" + error);
    }
    trace ("2 mNames 2:" + mNames [2]);
    trace ("2 dNames 3:" + dNames [3]);
    Stop();

    function completeHandler(event:Event):void
    {
    var loader: URLLoader = URLLoader (event.target);
    dNames = loader.data.dayNames.split(",");
    mNames = loader.data.monthNames.split (",");
    trace (Loader.Data.DayNames);
    trace ("1 mNames 2:" + mNames [2]);
    trace ("1 dNames 3:" + dNames [3]);
    }

    OUTPUT:

    2 mNames 2: undefined
    2 dNames 3: undefined
    Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
    1 mNames 2: March
    1 dNames 3: Wednesday

    How to access these values after the loading of the external file, after charging?

    Thanks in advance.

    The statement you quoted all Adobe documentation is correct.

    If you want to load the data into the tables before anything else happens, then have everything that happens to run via the function completeHandler... when the data is loaded and processed in the tables.

    the command: loadFile() runs before the trace ("2:" + images [4]); command.  The loadFile function is processed and loading process BEGINS... but begins loading does not delay the main treatment to continue down the line - the loading itself becomes a secondary/background task.  The order was to run the function loadFile and the processing of this function has been completed.  If you don't believe, then add a trace...

    function loadFile (): void

    {

    vars.dataFormat = pouvez;

    vars.addEventListener (Event.COMPLETE, onComplete, false, 0, true);

    Vars.Load (new URLRequest("images/fnames.txt"));

    trace ("implementation");

    }

    If you add this trace, you will see the execution of function loadFile is completed and the following line in your code is then treatment... trace (2...)

    The addEventlistener method does not stop anything.  The addEventListener method code is assigned a monitor, not a traffic controller... it's say the monitor to indicate when the loading data are complete.  It does not do anything to stop the execution of the program.

    So if you want to wait until the data is loaded before anything else... it goes...

    function onComplete(evt:Event):void

    {

    var urlVars:URLVariables = evt.target.data;

    images = vars.data.images.split(",");

    tnails = vars.data.thumbnails.split(",");

    ................ HERE.................

    }

  • load the file into the virtual machine

    How can I load any file to the virtual machine using java api

    How to download the file in the guest on VMware operating system:How to transfer the file to the operating system guest on VMware | DoubleCloud = & gt; Private cloud and Public Cloud

    How to download files from GOS on VMware:How to download a file from the operating system guest on VMware | DoubleCloud = & gt; Private cloud and Public Cloud

    If you have any question/problem related to this, please post on above blog

  • How to load a file into the app for IOS

    Dear friends,

    IAM creating an app for e-learning in iam android (in the AIR) by using the following code to load the respective lessons:

    var mv:Loader = new Loader();

    var req:URLRequest = new URLRequest("app:/Lessons/module/lesson1.swf");

    MV. Load (req);

    same thing iam using iOS (adobe AIR) his does not work pls help me load an external file in my application created with adobe air.

    Thank you and best regards,

    Syed Abdul Rahim

    1 make sure of course active loads (for example, lesson1.swf) are added to your panel of ' all files '.

    2. If the loaded file contains actionscript code that is not running, use:

    var mv:Loader = new Loader();

    var req:URLRequest = new URLRequest("app:/Lessons/module/lesson1.swf");

    var lc:LoaderContext = new LoaderContext(false,ApplicationDomain.currentDomain,null);

    MV. Load (Req, LC);

  • How to load multiple files into multiple tables using a Controlfile?

    Hello world

    I have four different tables with similar structures, get the data from four different data files. I would like to use one control file to load the data from four different files from four different tables.

    Here's the DOF of the tables:

    CREATE TABLE Product_Sales(  
        Year_of_Sale NUMBER,  
        Product_Type VARCHAR2(25 CHAR),  
        Product_Group VARCHAR2(25 CHAR),  
        Category_Type VARCHAR2(25 CHAR),  
        Category_Group VARCHAR2(10 CHAR),  
        Product_Count NUMBER,  
        Product_Amount NUMBER(19,2),  
        Category_Count NUMBER,  
        Category_Amount NUMBER(19,2)  
    )  
    
    

    CREATE TABLE Retail_Sales(  
        Year_of_Sale NUMBER,  
        Product_Type VARCHAR2(25 CHAR),  
        Product_Group VARCHAR2(25 CHAR),  
        Category_Type VARCHAR2(25 CHAR),  
        Category_Group VARCHAR2(10 CHAR),  
        Product_Count NUMBER,  
        Product_Amount NUMBER(19,2),  
        Category_Count NUMBER,  
        Category_Amount NUMBER(19,2)  
    )  
    
    

    You still have products_sales instead of product_sales in when your article, so it does not load anything in the product_sales table.  You have not reset the position for the first after subsequent field in the table and when clauses, then it starts looking for the first field to the position you left it in the previous section, instead of 1, so he can't find anything and does load all the data in the household_sales table.  You need to reset the position 1 for each combination of table and what clause after the first.  The first argument is optional.  Please see the corrected below control file.

    DOWNLOAD THE DATA

    INFILE 'output.txt '.

    IN THE PRODUCT_SALES TABLE TRUNCATE

    WHEN filename = "Product_Sales".

    FIELDS ENDED BY ',' POSSIBLY FRAMED BY ' '.

    TRAILING NULLCOLS

    (

    file name of FILLING,

    Year_of_Sale,

    Product_Type,

    Product_Group,

    Category_Type,

    Category_Group,

    Product_Count,

    EXTERNAL DECIMAL Product_Amount,

    Category_Count,

    EXTERNAL DECIMAL Category_Amount

    )

    IN THE HOUSEHOLD_SALES TABLE TRUNCATE

    WHEN filename = "Household_Sales".

    FIELDS ENDED BY ',' POSSIBLY FRAMED BY ' '.

    TRAILING NULLCOLS

    (

    filename FILLER POSITION (1),

    Year_of_Sale,

    Household_Type,

    Product_Group FILLING,

    Category_Type FILLING,

    Category_Group FILLING,

    Product_Count,

    EXTERNAL DECIMAL Product_Amount,

    Category_Count,

    EXTERNAL DECIMAL Category_Amount

    )

  • How to load csv file into external table

    I'm using oracle 11g xe edition.

    probably error-boy, but I can't "see

    Command line error: column 21:12

    Error report-

    SQL error: ORA-00906: lack of left parenthesis

    create the table rgc_ext

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20)

    )

    EXTERNAL ORGANIZATION

    (

    TYPE ORACLE_LOADER

    CER default DIRECTORY

    ACCESS SETTINGS

    (

    RECORDS DELIMITED BY NEWLINE

    FIELDS

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20).

    Sate DOB

    )

    )

    LOCATION 'info.csv '.

    );

    Hello

    Try with the following text:

    create the table rgc_ext

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20)

    )

    EXTERNAL ORGANIZATION

    (

    TYPE ORACLE_LOADER

    CER default DIRECTORY

    ACCESS SETTINGS

    (

    RECORDS DELIMITED BY NEWLINE

    ' fields completed by ',' EVENTUALLY ENCLOSED BY ' "'

    (

    First name VARCHAR2 (20).

    name vARCHAR2 (20).

    Sate DOB

    )

    )

    LOCATION ("info.csv")

    );

  • Load the text file into the Textarea

    Hi How can I load text files into Textarea I use this method seems like it load text file but I can't show it in a textarea a certain pls help

    Hi all
    Finally I found the way to load the text file into the textArea, that's like


    private function loadText (): void {}
    var l:URLLoader = new URLLoader (new URLRequest('2.txt'))
    l.addEventListener (Event.COMPLETE, finishLoading);

    }
    public void finishLoading(evt:Event):void {}
    var myData:String = new String (evt.target.data)
    txtBox.text = myData;
    }

    ]]>

    It should works because it is a work with me
    Take advantage of the code
    Sanji

  • Load a disk file into a BLOB

    I'm trying to load a file into a BLOB in 10 g express what I'm doing wrong?


    CREATE a DIRECTORY rpt_working_dir AS '... » ;

    GRANT READ, WRITE on DIRECTORY rpt_working_dir TO username;


    create the table blob_test
    (
    ID INTEGER,
    bin_data BLOB
    )


    insert into blob_test (id) values ('1')




    DECLARE
    src_file BFILE: = bfilename ('RPT_WORKING_DIR', '100.pdf');
    dst_file BLOB;
    lgh_file directory.
    BEGIN

    dst_file: = EMPTY_BLOB();
    -Open the file
    DBMS_LOB. FileOpen (src_file, dbms_lob.file_readonly);

    -determine the length
    lgh_file: = dbms_lob.getlength (src_file);

    -Read the file
    DBMS_LOB. LoadFromFile (dst_file, src_file, lgh_file);

    -update the blob field
    UPDATE blob_test
    SET bin_data = dst_file;
    COMMIT;

    -close file
    DBMS_LOB. FileClose (src_file);
    END;


    This results in this error:

    ORA-22275: specified incorrect LOB Locator
    ORA-06512: at "SYS." DBMS_LOB", line 637
    ORA-06512: at line 15 level
    22275 00000 - "specified incorrect LOB Locator.
    * Cause: There are several causes
    initialized; (2) the Locator is a BFILE type and routine
    expects a BLOB/CLOB/NCLOB Locator; (3) the Locator is for a
    BLOB/CLOB/NCLOB and routine expects a co-locator type BFILE.
    (4) to attempt to update the LOB in a body of trigger - LOBs in
    bodies of trigger are read-only; (5) the Locator is for a
    BFILE/BLOB and the routine expects a co-Locator CLOB/NCLOB;
    (6) the Locator for a CLOB/NCLOB and waiting for the routine
    a BFILE/BLOB Locator;
    * Action: (1) initialize the LOB Locator by selecting in the Locator
    variable or by defining the empty LOB index. For (2), (3),
    (5) and (6) pass the correct type of mark in the routine.
    (4), remove the trigger body code that updates the LOB value.

    Empty_blob must be equivalent to a null value. try to use DBMS_lob.create_temporary.

    Example of

    dbms_lob.createtemporary(,true);
    

    http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_lob.htm#i997788

    Alessandro Bye

  • Load a file in tiara with a use using LabVIEW

    Is it possible to load a file into tiara with a use that is customized by using LabVIEW.  I looked through the palette and see nothing.

    Hi Siriusly,

    I've added 2 additional lines of configuration of trainer to the use, and now that the last row of empty values has disappeared from a single file you sent me.

    Brad Turpin

    Tiara Product Support Engineer
    National Instruments

  • A way to load external files in applications WebWorks

    Hi all

    I am facing the following problem.

    My application is able to play the animation sequences of 16 colors on a screen of matrix of LED 34 x 18.

    I am working on a set of tools that make it relatively easy for people to create their own animations play in my application. I'd love to see what other people come up with.

    But here's the problem: how they load these new animations in my application? On Palm WebOS, it is possible to load a file from any Web host on this platform, I can simply tell the user to put a file on their Web host and enter the URL in my application.

    However, on the PlayBook every domain must be added explicitly permission in the file config.xml for the APP. Therefore, it is impossible for users to load their own Web host files in my application.

    Before I spend more time perfecting these tools for end users (I already use the myself but right now they are a little gross) so I need to know if it will be possible for users to put the files they have created with my tools on their playbook and whether it will be possible to load a file into my application at a given time for example by offering a "Browse" button which exposes the local file system to select a file.

    Is it possible (going to be)? If so, I also opened a repository for people to present animations created then possibly include in next updates of the application.

    Let me know!

    p.s. the app can be seen here.

    In the entertainment section you can see the various animations that I created with my tool. They are stored in a JSON file.

    You can whitelist ' *' to allow access from all domains.

    I think that this limits the possibility for all areas of access to the api specific blackberry however.

    I'm sure it's documented somewhere in the WebWorks getting started guides?

  • Muse is unable to load the files, only on the main computer

    Hi all

    I wonder if anyone has experienced this before, or has ideas on how to solve this problem.

    Worked on a site yesterday.  Hibernated as usual.

    Have went to use the program today to find that it hangs on the bird's eye view on any Web site file I load.

    No errors, it remains just completely inadmissible and needs to be forced to leave.

    The strange thing is my carry around portable can load the file perfectly (the same exact, located in a network Bank).

    I tried to record a new version of the computer that works.  My main computer crashes again.

    I tried to load the file into the pre-release, always falls down.

    I tried uninstalling the computer.

    Restart the computer.

    Installation.

    Still crashes.

    Tried to move the files locally.

    Still crashes.

    I checked the Windows Update, it did not do anything in this period.

    Am quite perplexed.

    Any suggestions would be greatly appreciated.

    I thought I'd try the system restore in Windows to see if it would help.  Went to restore a file from 2 days ago.

    System restore corrupted my Windows even more and because my main drive was Bitlocker protected, he has me very very grumpy and Windows was over.

    30 minutes of trying to fix, my computer now has a new installation of Windows.

    The good news is that muse is working again.

    TL:Dr: If you have a problem with Muse, wipe your entire computer, it suits him.

  • 4.2.3/.4 data support assistant - slow when loading large files

    Hello

    I use the load data wizard to load csv files into an existing table. It works very well with small files up to a few thousand rows. When loading 20 k lines or more loading process becomes very slow. The table has a unique numeric column to the primary key.

    The primary key is declared to the "shared components"-> logic-> "data loading tables" and is recognized as 'pk (number)' with 'case sensitve' set to 'No '.

    When loading the data, these Setup executes the following query for each line:

    Select 1 "Klaus". "' PD_IF_CSV_ROW ' where upper ("PK") = upper(:uk_1)

    which can be found in v$ sql view during loading.

    It makes the process of slow loading because of the superior function, no index can be used.

    It seems that the setting of "case sensitive" is not rated.

    Removing the numeric index for the key primary and with the help of a function based index do not help.

    Explain plan shows an implicit conversion "to_char":

    UPPER (TO_CHAR (PK) = UPPER(:UK_1)

    It is missing in the request, but perhaps that it is necessary for the function based index to work.

    Please provide a solution or workaround to load data Wizard work with large files in a reasonable time.

    Best regards

    Klaus

    You must have the correspondence of PK to be "exactly - case-sensitive" (or something like that)

    In addition, I was already on the slowness with Oracle Support when dealing with important content.

    They are aware of the problem.  Only around is known to break up the data into smaller segments.

    (I'll have to track down the correct ID for reference...)

    My observation:

    APEX data loader makes a slow-by-slow transformation of the data instead of treatment in bulk.

    You will need to break up the data, or to build your own data loader.

    Thank you

    MK

  • How to load several files DBF table 1 target using only 1 interface?

    Hello, I am a beginner in ODI and I have a problem.

    I have several DBF / Foxpro files that is stored in a directory like this:
    2010_10/account.dbf
    2010_11/account.dbf

    All DBF files have the same structure, but stored in a different folder (the folder name is < year > _ < month >)

    I managed to create an interface to load a DBF unique for the target table and the source table is hardcoded in the interface. Ideally, the interface will take place once a month.

    How can I use the same interface to load other DBF files?

    I know, if the data source is a text file, you can link the resource name to a variable, and the variable can be set to a file name. But I can't do since I use a JDBC driver to connect to the DBF file.

    Any help will be appreciated

    Hello

    I have no idea on the DBF files, yet...

    What is create a variable to build the 'months' and then pass this variable to OdiFileCopy, move this file to a specific directory. Then run your interface to load this file into your database. Once the work is successful, you can delete the file using OdiFileDelete (optional)

    Thank you
    Fati

  • APEX 5: FILE item type to BROWSE not load file into the table apex_application_temp_files

    Hello

    I am trying to load the BLOB (CSV file) into apex_application_temp_files table using the file_browse item type. I have created an example page and the added element of type file_browse, added a dynamic action, which send item to browse.

    Also added a button load that submits the page. But when I check the apex_application_temp_files of APEX sql workhop table, nothing appears.

    I purge file to "end of Session. Enclosed screen shot as well.Capture.PNG

    Thank you

    Ankit

    Hi Pierre,.

    has added a dynamic action, submitting travel item.

    How can you submit just the element go? How your dynamic action look like?

    But when I check the apex_application_temp_files of APEX sql workhop table, nothing appears.

    It is by design, because the sight of apex_application_temp_files limited to your current session. In your case at the session of constructor and not your application.

    Add a process to the page that contains the item "Browse file" when you use

    select *
      from apex_application_temp_files
     where name = :page item name;
    

    to access your downloaded BLOB.

    Concerning

    Patrick

  • Load the XML file into Oracle external Table


    I load the data from the XML file into an intermediate table Oracle using external Tables.

    Let's say below, it is my XML file

    < header >
    < A_CNT > 10 < / A_CNT >
    < E_CNT > 10 < / E_CNT >
    < AF_CNT > 10 < / AF_CNT >
    < / header >
    < student >
    <>students-details
    < Student_info >
    < Single_Info >
    < ID > 18 / < ID >
    New York < City > < / City >
    < country > United States < / country >
    < Name_lst >
    < Student_name >
    Samuel < name > < / name >
    Paul < Last_name > < / Last_name >
    < DOB > 19871208 < / DOB >
    Aware of < RecordStatus > < / RecordStatus >
    < / Student_name >
    < Student_name >
    Samuel < name > < / name >
    Paul < Last_name > < / Last_name >
    < DOB > 19871208 < / DOB >

    < TerminationDt > 20050812 < / TerminationDt >
    History of < RecordStatus > < / RecordStatus >
    < / Student_name >
    < / Name_lst >
    < Personal_Info >
    <>men < / Type >
    < 27 > < / Age >
    < / Personal_Info >
    < / Single_Info >
    < / Student_info >

    < student - register >
    class < A >
    < info >
    < detail >
    < ID student > 18 < / student >
    EE < major > < / Major >
    < course-Grades >
    < course > VLSI < / course >
    < degree > 3.0 < / Grade >
    < / course-Grades >
    < course-Grades >
    < course > nanotechnology < / course >
    < degree > 4.0 < / Grade >
    < / course-Grades >
    < / details >
    < detail >
    < ID student > 18 < / student >
    THIS < major > < / Major >
    < / details >
    < / info >
    class < A >
    < Student_Enrol >
    <>students-details
    < student >

    I load this XML data file into a single table using an external Table. Could someone help me please with coding.

    Thank you

    Reva

    Could you please help me how to insert my XML content into that.

    Same as before, try a plain old INSERT:

    insert into xml_pecos

    values)

    XmlType (bfilename ('XML_DIR', "test.xml"), nls_charset_id ('AL32UTF8'))

    );

    But you'll probably hit the same limitation as with the binary XMLType table.

    In this case, you can use FTP to load the file as a resource in the XML DB repository.

    If the XML schema has been registered with the hierarchy enabled then the file will be automatically inserted into the table.

    Could you post the exact statement that you used to save the scheme?

    In the meantime, you can also read this article, I did a few years ago, it covers the XML DB features that may be useful here, including details on how to load the file via FTP:

    https://odieweblog.WordPress.com/2011/11/23/Oracle-XML-DB-a-practical-example/

    And documentation of the course: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb06stt.htm#ADXDB4672

Maybe you are looking for

  • I DROPPED MY PHONE WITH THE HELP OF TOILET

    I have an iPhone 5, it has been used since about 2013. I have fallen into the clean toilet last night, immediately he came out, took off my case, then he wiped. Being the fool that I am, I turned on the phone and checked to see if the screen worked.

  • Authentication port GS108T with 802.1 x problem

    Recently, I bought a couple of switches GS108T I'm supposed to use with the authentication of 802. 1 x. I've implemented a PKI structure that works well and uses NPS (network POLICY server) on Win 2 k 8 to manage the 802. 1 x. It did not work and aft

  • Sending photos embeded in any e-mail program on a computer

    Anyone know if it is possible to send photos of embeded in any e-mail program on a computer with Windows 7 64 bit. Not as an attachment. Billy the kid

  • Lost data to the address book on blackBerry Smartphones

    I lost all data in my address book but it shows 33 entries that is correct - I can't just change settings for viewing. All new addition also of do not display. Blackberry manual doesn't show settings to address this problem. Any suggestions will be a

  • Check if the Oracle memory usage is critical

    Hi allI'm in Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 and I would like to know how if it is possible to detect any evidence that Oracle may encounter a problem of memory.I know how to get STATS$ SGASTAT and STATS$ PGASTAT for histor