I've managed to create a (relatively) stable data-processing class which
behaves a bit like Excel, but with some of Ruby's awesome syntax styles.
I've used it on a few projects now so I'm happy with how it works,
although I'm always trying to improve it.
The 2 files are intended to be placed in the same directory. I might
break it down further in a later build.
This was written to be documented with "yard" if that makes the random
layout easier on the eyes.
The intention is to help simplify scripts which have to sift through
table data, by allowing the user to work with a variety of ways to
access
and loop though the data. The class is built around the assumption that
it is dealing with a 2D array of data with headers in the first row,
which it generally tries to avoid touching while looping through the
data. The
indexing is 1-based to mimic Excel's API.
There are multiple ways to reference the data. You can do this by Row,
Column, Cell indices, Ranges, and individual addresses using [].
I've found this a happy medium between the slowness of Excel's clunky
VBA, and the frustration of having to constantly move Ruby's Array
indices around to avoid affecting the headers.
If I can get rid of the bugs in this and add enough useful functionality
then I might publish it as a gem for anyone who regularly has to deal
with tables (HTML in my case) and wants a simple tool to do it with.
Any comments, advice, requests or constructive criticism are welcome!
Special thanks to Robert Klemme for providing the impetus to get this
started.
Attachments:
http://www.ruby-forum.com/attachment/8208/RubyExcel.rb
http://www.ruby-forum.com/attachment/8209/RubyExcel_Components.rb
···
--
Posted via http://www.ruby-forum.com/.