Skip to main content

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.

Comments

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

Alvaro
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
true

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 ?

Regards,
Fateh
Scott said…
Fateh,

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

Thanks,

- 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?

Thanks!
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:

http://krisrice.blogspot.com/2010/02/another-apex-listener-ea-more-knobs-to.html

Thanks,

- Scott -
Scott said…
And another reference:

http://www.ora600.be/news/apex-listener-ea2-native-excel-upload
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.

Thanks
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.

Thanks,

- Scott -

Popular posts from this blog

Custom Export to CSV

It's been a while since I've updated my blog. I've been quite busy lately, and just have not had the time that I used to. We're expecting our 1st child in just a few short weeks now, so most of my free time has been spent learning Lamaze breathing, making the weekly run to Babies R Us, and relocating my office from the larger room upstairs to the smaller one downstairs - which I do happen to like MUCH more than I had anticipated. I have everything I need within a short walk - a bathroom, beer fridge, and 52" HD TV. I only need to go upstairs to eat and sleep now, but alas, this will all change soon... Recently, I was asked if you could change the way Export to CSV in ApEx works. The short answer is, of course, no. But it's not too difficult to "roll your own" CSV export procedure. Why would you want to do this? Well, the customer's requirement was to manipulate some data when the Export link was clicked, and then export it to CSV in a forma

Refreshing PL/SQL Regions in APEX

If you've been using APEX long enough, you've probably used a PL/SQL Region to render some sort of HTML that the APEX built-in components simply can't handle. Perhaps a complex chart or region that has a lot of custom content and/or layout. While best practices may be to use an APEX component, or if not, build a plugin, we all know that sometimes reality doesn't give us that kind of time or flexibility. While the PL/SQL Region is quite powerful, it still lacks a key feature: the ability to be refreshed by a Dynamic Action. This is true even in APEX 5. Fortunately, there's a simple workaround that only requires a small change to your code: change your procedure to a function and call it from a Classic Report region. In changing your procedure to a function, you'll likely only need to make one type of change: converting and htp.prn calls to instead populate and return a variable at the end of the function. Most, if not all of the rest of the code can rem

Manipulating Images with the... Database?

A recent thread on the OTN HTML DB Forum asked about how to determine the width & height of an image stored as a BLOB in an Oracle table. I mentioned in that thread that I have some code to manipulate an image stored in a BLOB column. This is particularly useful if you’re going to let users upload images, and you want to re-size them to display as a thumbnail. Thanks to Oracle interMedia , it is trivial to manipulate the width, height, and other attributes of images stored in an Oracle table. I’ve created a sample application here which demonstrates Oracle interMedia and HTML DB in action. Feel free to have a look. You can download this application from HTML DB Studio as well. Basically, this application allows you to upload images and perform an operation on the image as it is inserted into the PHOTO_CATALOG table. There are two places where some PL/SQL code is required: an After Submit process on page 2, and a procedure to display the images. Here is the PL/SQL for the After