I’m looping through an Excel spreadsheeet, acquiring cells, and adding
the data to a ruport table. I want access to the record just
appended, but unsure of how to get to it. Code follows:
begin
@tbl_PAS << { # append row into table
:clientid =>
get_cell_as_text(row,@buildlist[:clientid]),
:wdatetime =>
get_cell_as_date(row,@buildlist[:wdatetime]),
:emp => emp_merge(row),
:whours => get_cell_as_num(row,@buildlist[:whours]),
…
}
rescue
puts “Unexpected error inserting data into table.”
puts options.inspect
raise
end
# tag record for summary counts
case
when r.proj[0,4] == 'ADMN'
r.tag(:Administration)
when r.task[0,5] == 'AL916'
t.tag(:Support)
…
I want r. to the last record appended. I was hoping r = @tbl_PAS <<
would be it. But r points to the table, not the last record appended.
Thanks. Sometimes “too easy” makes one feel really dumb. I’m trying
to exploit all the capabilities of Ruport’s tabling handling – and
struggling. I don’t know why this is seeming so difficult. I now get
an error when using group_by_tag. In my data load, I’ve done the
following:
def apply_category(r)
case
when r.proj[0,4] == ‘ADMN’
r.tag(:Administration)
when r.task[0,5] == ‘AL916’
r.tag(:Support)
when (r.task[0,2] == ‘IS’ or
r.proj == ‘76011’ or
r.proj == ‘75634’ or
r.proj == ‘75638’)
r.tag(:Development)
else
r.tag(:Other)
end
end
When I attempt to utilize those tags, things go south. I’ve
attempted:
def cat_hours(c)
hrs = 0
t = @tbl_PAS.group_by_tag(c)
#@tbl_PAS.group_by_tag(:Development).each {|r| hrs += r.whours}
printf “%-15s = %5.2f\n”,c,hrs
end
If you have any suggestions, that would be much appreciated. What I
am doing is attempting to deal with the increased time reporting
demands of my company. Their time tracking system is dismal, but it
exports data to Excel. So I want to table everything, categorize it
at will, and produce six or seven different summaries from the various
data elements available.
I’m trying to exploit all the capabilities of Ruport’s tabling
handling – and struggling.
You might really want to consider taking Greg’s advice then and
asking the Ruport list directly. I don’t say that to be mean, I’m
just betting the people there are much more likely to know the exact
answers to your questions. (I don’t sadly, or I would answer them.)
I know Greg tries to keep one eye on Ruby T., but I’m sure he
misses some things. He sees every single message on the Ruport list
though, as do numerous other experienced Ruport users.
The list is a Google Group, so you can interact with it completely
from their web interface and not have to hassle with more email
messages. I always find that nice when I just want to ask a few
questions.
Anyway, just a thought. Good luck with your report.
James Edward G. II
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.