Ruport, Table append, access to record


#1

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.

Any advice?
dvn


#2

I’ve attempted the following, but it is not buying it. I get a tassoc
error?

        r = Ruport::Data::Record.new {
            :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]),

}


#3

On 2/25/07, removed_email_address@domain.invalid removed_email_address@domain.invalid wrote:

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.

try:

r = @tbl_PAS[-1]

This should do the trick.

For further questions, please come catch up with us on the Ruport list.
http://list.rubyreports.org

-greg


#4

On Feb 25, 1:37 pm, “Gregory B.” removed_email_address@domain.invalid wrote:

For further questions, please come catch up with us on the Ruport list.http://list.rubyreports.org

-greg

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®
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©
hrs = 0
t = @tbl_PAS.group_by_tag©
#@tbl_PAS.group_by_tag(:Development).each {|r| hrs += r.whours}
printf “%-15s = %5.2f\n”,c,hrs
end

But I am typically greeted with “Exception: undefined method
`group_by_tag’ for #Ruport::Data::Table:0x2d6c700

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.

thanks again,
dvn


#5

On Feb 25, 2007, at 5:45 PM, removed_email_address@domain.invalid wrote:

On Feb 25, 1:37 pm, “Gregory B.” removed_email_address@domain.invalid wrote:

For further questions, please come catch up with us on the Ruport
list.http://list.rubyreports.org

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