Friday, February 12, 2010

Uploading XLS Files with APEX Listener EA2

Kris Rice just posted that the APEX Listener EA2 is available for download.

Quoting Kris on the new features:

  • New /listenerAdmin with real-time statistics
  • Mechanism for logging DB Requests
  • Capability to upload .xls files into an APEX Collection

The last of these features interests me the most, as we get that request all of the time.  The de facto solution is to save your Excel data as CSV, then upload that.  Not very elegant.

So before even completing my first cup of coffee this morning, I decided to try it out.

Downloading the new listener was as snap, as was re-deploying the .war file.  Took no time at all, and I was up and running.

Next, I created a quick little application that simply had a File Browse item on the page and a button whose request value is set to 'XLS2COLLECTION', as per Kris's instructions.  I ran the application, located an XLS file, and clicked "Go".  Upon checking the session state for collections, the results were a little different than Kris outlined.

The one potentially major flaw with how its currently implemented is that the item name - not ID - of the item is used for the collection name.  Since APEX sets the item's ID to be the same as the APEX item name that developers enter, this is inconsistent and will likely cause some confusion.

One would expect that if I called the File Browse item "P1_XLS_FILE" that my collection name would also be called "P1_XLS_FILE".  This is not the case;  rather, the collection name is called "P_T01" - which if you look at the HTML source, is the item name associated with P1_XLS_FILE.

If you add additional items to the page before P1_XLS_FILE, its name will change accordingly.  Simply adding a text field with a lower sequence number than P1_XLS_FILE in my test application caused the item name to change to P_T02.

Hopefully, Oracle will address this and make it more consistent, so that we as developers can easily get the name of the collection that was just created.

Despite this flaw, this is an amazing feature, which is likely to save a lot of people a lot of time.

Just to be thorough, I also tested it with the newer XLSX format, and not surprisingly, it did not work.  Thus, be sure to save your XLS spreadsheets to the more commonly used XLS format before using this feature.

You can download my test application here.  Keep in mind that you'll also need to have the current APEX listener installed on your server for this to work.


Anonymous said...

Scott, have you installed the Apex Listener EAD under Mac OS X ? Thanks,


Scott said...

Yes, I do.

From what I remember, you have to install JDK 1.6 and make sure that is your current version.

Thus, when you run this command:

java -version

This is what you should get back:

java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-10M3025)
Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode)

Hope this helps.

- Scott -

fateh.cis said...

Hello Mr. Scott,

I use apex 4.1 with apex listener 1.1.3 deployed on Glassfish 3.1.

I installed your app. then added this entry

to apex configuration file ( I found to files on my C drive. on Temp and on Apex folder ) However, I added the entry to the both.

Then I added a text item to your app by the name of P_T01.

Then I tested the functionallty. but it did not work...
Can you help me to pinpoint the problem ?


Scott said...


I think that the way that this works has changed. You may want to check the docs w/the APEX listener for more details.


- Scott -

Josep Coves said...

Hi Scott,

Do you know if this functionality is avaliable at the current APEX Listener 1.1.3 version from oracle?


Scott said...

I checked w/Kris Rice from Oracle, and he verified that yes, it can still do this.

The method that I described in this post are dated. Have a look at Kris's blog for an updated version:


- Scott -

Scott said...

And another reference:

Josep Coves said...

Hi Scott,

Thanks, I finally got it working... In fact it was already working fine... the problem I had is I was for two reasons:

1) The collection name is not simply the APEX ITEM but it concatenates the excel sheet name. I solved that whit a like condition: collection_name like 'P1_FILE%'

2) I was trying to upload an excel with more than 50 columns

Do you know if there's any way to create a collection with more than 50 columns or to split it into two different collections? My main problem is I cannot modify excel source files, because they are generated from a third party software.


Scott said...

The limitation is set to 50, as that's how many columns are in the APEX_COLLECTIONS table.

If they decide to increase this in APEX 4.2, then perhaps the limitation will increase as well. But for now, you're stuck with 50.


- Scott -