Parsing Excel Files with ActionScript 3.0

Back in January, I had started learning ActionScript 3.0 by picking a particularly interesting problem that had been dogging me since I first started building web-based applications in the late 1990s. That problem is, how to build client-side programs that can parse and render binary file formats within a browser without the need to download separate plugins or ActiveX controls for each one. To do that, you need to able to parse binary data on the client. And when I saw the ByteArray class in Flex 2.0, I smiled.

I decided to go after Excel files. Yes, many machines have Excel or comparable spreadsheet application already installed on them. And Microsoft does offer a free downloadable viewer for Excel files. But wouldn’t it be just neat-o to be able to view Excel documents directly in the browser without needing anything but the Flash Player? Or even better yet, import data straight from .xls files into a Flash RIA?

After a few nights of work, I managed to import some basic .xls files and correctly parse out column and row data for strings and numbers. That was January, and then a maelstrom of client work happened (including a particularly painful stretch of 12 consecutive 16-hour workdays at a remote site). And the Flex 2.0 APIs changed. And changed again with each new beta. Not that I blame Adobe–each time it’s been for the better. Seriously, does anyone like having to import trace in every single class that you’re debugging? It was just that I hardly had time to sleep, let alone code anything fun. Thankfully, my good friend Darron Schall had been keeping my code updated to the latest versions of the Flex 2.0 beta in preparation for his recent presentation at Flash in the Can.

However, I’ve finally managed to get back to working on it, updating it yet again to Beta 3, adding a couple new features, and preparing it for public consumption. Next up is allowing for the file path to the .xls file to be specified programmatically (it’s currently hard-coded), and exposing the parser as a library that can be used by other projects.

So, without further ado, here’s a couple of demos: A very basic test, as both the Excel file and loaded into my Flash-based viewer. And a slightly more complex example, with the data available as the Excel file and loaded into the viewer (requires Flash Player 9).

4 Comments »

  1. Andre Charland said,

    May 18, 2006 @ 3:09 pm

    hey that’s pretty cool! we’re working on something related in AJAX. Don’t have any of the parsing stuff though. Mostly the eidtable AJAX Spreadsheet. Check it out here: http://labs.ebusiness-apps.com/technologies/spreadsheet/default.asp Would love to chat with you about your project and collaborate is possible.

  2. herve de CHAVIGNY said,

    July 3, 2006 @ 7:48 pm

    can you send me the sources code of your excel parser or a part of this because I want read a xls file to manage data in a flash apps!

    soory for my english language , but i’m a french people!

  3. Lance said,

    July 6, 2006 @ 8:21 am

    Very cool! If possible is there a chance to get the source code for this? Even a basic example would help to understand enough to get started on my own.

    Thx!

  4. Firdosh Tangri said,

    September 18, 2006 @ 5:38 pm

    Yes would it be possible to post the source code up for the project. I dont know if your still developing the project but it would be very helpfull to a lot of people and could probably help with the project :)

    thanks
    cheers :)
    firdosh

RSS feed for comments on this post · TrackBack URI

Leave a Comment