Karaoke For A Cure

Posted by Brian in News, Projects (January 24th, 2007)

I’m proud to be sponsoring this year’s Karaoke For A Cure contest, a benefit for the Eau Claire American Cancer Society. We’re developing the web site and providing the domain and hosting this year. Visit the site here.

Excel Export, the Stupid Simple Way

Posted by Brian in Rails, snacks (January 24th, 2007)

It occurred to me the other night while helping Mike figure out how to prepare some reports in Excel from a Rails application that it probably wasn’t necessary to use the plugin I created. One of the big drawbacks to the Excel Export plugin is that it doesn’t currently support formatting of cells. (There just really isn’t a good way to do that.) One trick I’ve known about for years is the ability for Excel to read in an HTML table of data and render it as a spreadsheet.

This meant that we could simple create a new view that contained the HTML table


Last Name First Name Birthday Email
<%=user.last_name %> <%=user.first_name %> <%=user.birthday %> <%=user.email %>

Then it’s just a simple matter of making a controller action to display that view.

  def export
    headers[’Content-Type’] = “application/vnd.ms-excel”
    render :layout=> false
  end

That should cause the browser to open Excel, instead of displaying the page. Now, I can’t guarantee that this will work on Linux, OSX, or anywhere where Excel is not installed. However it certainly meets our needs for this one project and so I t hought I would share it with everyone else.