Skip to content

A Rails plugin to generate xls documents by using rxls templates. Updated to work with Rails 3 without deprecation warnings.

License

Notifications You must be signed in to change notification settings

cknoxrun/spreadsheet_template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SpreadsheetTemplate
==================

A Rails plugin to generate xls documents by using templates.

Based on Spreadsheet on Rails (by Koen Van der Auwera) (http://github.com/10to1/spreadsheet_on_rails) and
CSV Builder (by Gabe da Silveira) (https://github.com/dasil003/csv_builder).

Dependencies
============

spreadsheet

Example
=======

Example spreadsheet usage as found here: http://github.com/jacobat/ruby-spreadsheet

-- in the view "index.xls.xlsbuilder

sheet = workbook.create_worksheet
sheet.name = "What's in a name"

sheet.row(0).concat %w{Name Country Acknowlegement}
sheet[1,0] = 'Japan'
row = sheet.row(1)
row.push 'Creator of Ruby'
row.unshift 'Yukihiro Matsumoto'
sheet.row(2).replace [ 'Daniel J. Berger', 'U.S.A.',
                        'Author of original code for Spreadsheet::Excel' ]
sheet.row(3).push 'Charles Lowe', 'Author of the ruby-ole Library'
sheet.row(3).insert 1, 'Unknown'
sheet.update_row 4, 'Hannes Wyss', 'Switzerland', 'Author'

sheet.row(0).height = 18

format = Spreadsheet::Format.new :color => :blue,
                                 :weight => :bold,
                                 :size => 18
sheet.row(0).default_format = format

bold = Spreadsheet::Format.new :weight => :bold
4.times do |x| sheet.row(x + 1).set_format(0, bold) end


-- in the controller

def index
  @lines = Line.find(:all)

  respond_to do |format|
    format.html # index.html.erb
    format.xml  { render :xml => @lines }
    format.xls  { render :action => "index", :layout => false }
  end
end

About

A Rails plugin to generate xls documents by using rxls templates. Updated to work with Rails 3 without deprecation warnings.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%