Hello New to ruby :) 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 19, 1:33 pm, Fred <fer...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Hello > New to ruby :) > 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.> 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 appreciatedYour 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On May 19, 2:59 pm, Jeff <cohen.j...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 19, 1:33 pm, Fred <fer...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > > > Hello > > New to ruby :) > > 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. > > > > > 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 > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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.> > > > On May 19, 2:59 pm, Jeff <cohen.j...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On May 19, 1:33 pm, Fred <fer...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote: > > > > > Hello > > > New to ruby :) > > > 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. > > > > > > > > > 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 > > > > 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---