Skip to content

Commit

Permalink
Add a small example and description for the renderer option.
Browse files Browse the repository at this point in the history
  • Loading branch information
raskhadafi committed Jan 27, 2012
1 parent db21fd1 commit 7b53de8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ excel_document(:filename => "report.xls", :template_path => "/tmp/report_templat
... # any staff form previous example
end

If you provide a :renderer option to the excel_document method, you can use your customized Spreadsheet::Workbook to create a newe excel file.

Your view "index.xls.rxls" file could look like this:

excel_document(:filename => "foobar.xls", :renderer => Spreadsheet::CustomWorkbook) do |workbook|
workbook.new_worksheet("#{t_model(Product)}")
end

And the renderer class ("lib/spreadsheet"):

module Spreadsheet
class CustomWorkbook < Spreadsheet::Workbook

attr_accessor :sheet

def new_worksheet
@sheet = workbook.create_worksheet
@sheet.name = "What's in a name"
end
end
end

-- in the controller

def index
Expand Down

0 comments on commit 7b53de8

Please sign in to comment.