Newbie

Hello
New to ruby :slight_smile:
i have to current code :
xml.Worksheet ‘ss:Name’ => ‘Sheet1’ do

    xml.Table do

      # Header
      xml.Row do

        for column in @model.content_columns do
          xml.Cell do
            xml.Data column.human_name, 'ss:Type' => 'String'
          end
        end
      end

      # Rows
      for record in @export
        xml.Row do
          for column in @model.content_columns do
            xml.Cell do
              xml.Data record.send(column.name), 'ss:Type' =>

‘String’
end
end
end
end

    end
  end

it does extract data to an excel worksheet.
Where @model is the model name ( ex: User)
and @export is record set( ex: @export=User.find(:all) )

i want to eliminate some columns of being extracted. Let’s say i want
to export just the first_name and not the whole table
Any suggestion will be appreciated
Thank you
Fred

On May 19, 1:33 pm, Fred [email protected] wrote:

Hello
New to ruby :slight_smile:
i have to current code :

I have a feeling you’ve taken this code from somewhere on the web
without first trying to understand it. Am I right? If so: DON’T DO
THAT. Understand the code before you steal the code. But see below
for my hint.

          end
            end

i want to eliminate some columns of being extracted. Let’s say i want
to export just the first_name and not the whole table
Any suggestion will be appreciated

Your problem is you don’t understand what @model.content_columns is
doing: it’s getting all the columns for that model. If you want only
specific columns, then just get the data for the columns you want.

Jeff

Hey though
i didnt steal it from anywhere. it comes with a pluging as a sample
code. I’m looking for help here and not for philosophers.

I use a find_by_sql instead of find(:all), so am just extracting 1
column (first_name).
i got the following error : missing attribute: middle_name.
maybe because the headers and columns numbers should map?
Anyone have an idea about what’s going on?
Thank you

Anyone have an idea about what’s going on?

Yes

I use a find_by_sql instead of find(:all), so am just extracting 1
column (first_name).
i got the following error : missing attribute: middle_name.
maybe because the headers and columns numbers should map?

Doing a find_by_sql whilst only selecting some columns from the table
won’t
make content_columns play nicely because content_columns expects the
returned object to have ALL the columns.

I’m looking for help here and not for philosophers.

May I point out to you that the help is free. Be prepared to get some
responses you won’t like.

I have a feeling you’ve taken this code from somewhere on the web

      # Header
      for record in @export
    end

Your problem is you don’t understand what @model.content_columns is
doing: it’s getting all the columns for that model. If you want only
specific columns, then just get the data for the columns you want.

Jeff

Thank you
Fred

–
Appreciated my help?
Recommend me on Working With Rails
http://workingwithrails.com/person/11030-ryan-bigg