Creating Reports on the Desktop
(Page 1 of 4 )
You may know how create a report in Ruby using the Active Record, but that's only half the battle. Reports aren't any good if the users they're intended for can't read them. This article will explain how to adjust reports so that they're more user-friendly to their intended audience. It is excerpted from chapter four of the book
Practical Reporting with Ruby and Rails, written by David Berube (Apress; ISBN: 1590599330).
In the previous chapters, you've learned about creating reports using Active Record. However, its not enough to simply create a report; you need to place the report in a context where it will be useful. Often, this means making the report accessible on the users' desktop in a format that's familiar to them. You can accomplish this in a number of ways, as you'll learn in this chapter.
Choosing a Desktop Format One powerful way to deliver reports to your users is to create a stand-alone graphical user interface (GUI) application that they can run on their desktop. This application can blend in with native applications written in other languages, so it will be familiar to the users. Furthermore, it won't be subject to the security restrictions that apply to web applications, so it can even control other applications-launching them and so forth.
Of course, deploying desktop applications isn't an option for some applications. Many Ruby developers are restricted to deploying web applications only. If that's true for you, you'll need an alternate approach.
One alternative is to offer the users the ability to download a file that can be opened in a desktop application. A common example is a Microsoft Excel file, which is familiar to many businesspeople. This is a useful approach, since many office workers have been trained to do simple calculations on Excel spreadsheets. (Of course, Microsoft Excel files can be opened in OpenOffice.org as well, so it's something of a spreadsheet lingua franca.)
Note Currently, there aren't any open source solutions for creating Microsoft Word or PowerPoint documents; Microsoft's proprietary format can make interoperability difficult. Additionally, Word and PowerPoint are commonly used for presentation purposes, and they can often be supplanted by HTML and PDF versions. You've already done several HTML examples. Chapters 6, 8, and 10 have examples of PDF output.
In this chapter, you'll create a formatted spreadsheet for the end user, and then you'll see how to create a fully functional GUI application.
CONTROLLING QUICKTIME WITH A DESKTOP APPLICATION
An example of a useful desktop application is one that I created for The Casting Frontier, a digital casting
services firm. This application uses FXRuby and the RubyOSA (rbosa) AppleScript library to control QuickTime Pro on Mac OS X.
The program automates the process of
storing national commercial auditions online. Before this solution, the
camera operators, who videotaped the auditions, needed to manually export each movie to a file, manually export the first frame of a movie as a thumbnail, make sure both files were named according to a convention, and then manually upload the file through FTP. (They also had a system to associate an actor’s digital profile with a movie; if the users wanted to use this, the process became even more complicated.)
Using the new application, the users simply entered the actor’s information,
clicked Start, clicked Stop, and then
clicked Upload. This sped up the process considerably.
If the solution were a web application, it would have been impossible to control QuickTime in order to export the movies and thumbnails. The camera
operators would have needed to do it by hand, which would slow them down and cost money. The solution also reduced errors, since it ensured that all of the movie files and thumbnail files were correctly named and labeled. In fact, the time factor was very significant. Auditions are held in rented rooms, which cost extra if auditions run overtime. Also, if actors wait longer than a certain time, the casting director holding the audition must pay a large fee to the actors' union.
Exporting Data to Spreadsheets
Generally, clients love spreadsheets. Often, they don't have the expertise to manipulate data using SQL or a programming language like Ruby, but they do know how to perform calculations and analyze data using Microsoft Excel or a similar tool. If their data is directly delivered in their format of choice, they can skip a step and save time. (In fact, some less computer-savvy users may not realize that they can copy and paste data from a web page, so exporting to an Excel-compatible format may enable them to act on data in ways they could not before.)
Next: Generating an Excel Spreadsheet >>
More Ruby-on-Rails Articles
More By Apress Publishing