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

Thanks, ODC (Oracle Developer Community)!

I owe a lot of thanks to the ODC - which stands for Oracle Developer Community.  What is ODC?  You may remember it as OTN, or the Oracle Technology Network.  Same people, different name.  Why they changed it I can't say.  People just liked it better that way... (love that song)

In any case, what am I thankful for?  A lot.  To start, the tools that I use day in and day out: SQL Developer, ORDS, Oracle Data Modeler, SQLcl and - of course - APEX.  Without these tools, I'm likely on a completely different career path, perhaps even one that aligns more closely with my degree in television management.

While the tools are great, it's really the people that make up the community that make ODC stand out. From the folks who run ODC and the Oracle ACE program to the developers and product managers who are behind the awesome tools, the ODC community is one of, if not the greatest asset of being involved with Oracle's products.

If you have yet to get more involved with this communi…

Spaced Out

A while back, I wrote about how to give the Universal Theme a face lift.  If you follow the steps in that post, the base font for an APEX application with the Universal Theme can easily be changed.

While that's all well and good, sometimes you only want to change the font for a report, not the entire page.  One of the applications that I'm building contains a number of IRs based mostly on log data.  Thus, having that data in a monospaced font would make it a whole lot easier to read.

You can search Google Fonts for monospaced fonts by selecting only that option on the right-side menubar.  You can also opt for the standard yet kinda boring Courier and achieve the same thing.

To implement this in your application, follow the steps in my other post, but stop shy of the final step.  Instead of pasting in the text that I specify, paste in the following to the Custom CSS field in Theme Roller, using the name of the font you selected for the font-family:

.a-IRR-table tr td { font-fam…

Logging APEX Report Downloads

A customer recently asked how APEX could track who clicked “download” from an Interactive Grid.  After some quick searching of the logs, I realized that APEX simply does not record this type of activity, aside from a simple page view type of “AJAX” entry.  This was not specific enough, and of course, led to the next question - can we prevent users from downloading data from a grid entirely?

I knew that any Javascript-based solution would fall short of their security requirements, since it is trivial to reconstruct the URL pattern required to initiate a download, even if the Javascript had removed the option from the menu.  Thus, I had to consider a PL/SQL-based approach - one that could not be bypassed by a malicious end user.

To solve this problem, I turned to APEX’s Initialization PL/SQL Code parameter.  Any PL/SQL code entered in this region will be executed before any other APEX-related process.  Thus, it is literally the first place that a developer can interact with an APEX page…