excel_rails 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/README +22 -0
  2. data/VERSION +1 -1
  3. data/excel_rails.gemspec +10 -10
  4. data/lib/excel_rails.rb +2 -1
  5. metadata +5 -5
data/README CHANGED
@@ -77,6 +77,28 @@ excel_document(:filename => "report.xls", :template_path => "/tmp/report_templat
77
77
  ... # any staff form previous example
78
78
  end
79
79
 
80
+ If you provide a :renderer option to the excel_document method, you can use your customized Spreadsheet::Workbook to create a new excel file.
81
+
82
+ Your view "index.xls.rxls" file could look like this:
83
+
84
+ excel_document(:filename => "foobar.xls", :renderer => Spreadsheet::CustomWorkbook) do |workbook|
85
+ workbook.new_worksheet("#{t_model(Product)}")
86
+ end
87
+
88
+ And the renderer class ("lib/spreadsheet"):
89
+
90
+ module Spreadsheet
91
+ class CustomWorkbook < Spreadsheet::Workbook
92
+
93
+ attr_accessor :sheet
94
+
95
+ def new_worksheet
96
+ @sheet = workbook.create_worksheet
97
+ @sheet.name = "What's in a name"
98
+ end
99
+ end
100
+ end
101
+
80
102
  -- in the controller
81
103
 
82
104
  def index
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.3.0
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{excel_rails}
8
- s.version = "0.2.3"
7
+ s.name = "excel_rails"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Aditya Sanghi}]
12
- s.date = %q{2011-09-04}
13
- s.description = %q{Allows you to program spreadsheets using .rxls views}
14
- s.email = %q{asanghi@me.com}
11
+ s.authors = ["Aditya Sanghi"]
12
+ s.date = "2012-01-27"
13
+ s.description = "Allows you to program spreadsheets using .rxls views"
14
+ s.email = "asanghi@me.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
17
  "README"
@@ -29,10 +29,10 @@ Gem::Specification.new do |s|
29
29
  "test/helper.rb",
30
30
  "test/test_excel_rails.rb"
31
31
  ]
32
- s.homepage = %q{http://github.com/asanghi/excel_rails}
33
- s.require_paths = [%q{lib}]
34
- s.rubygems_version = %q{1.8.9}
35
- s.summary = %q{Hook rxls to generate Excel documents in Rails 3}
32
+ s.homepage = "http://github.com/asanghi/excel_rails"
33
+ s.require_paths = ["lib"]
34
+ s.rubygems_version = "1.8.11"
35
+ s.summary = "Hook rxls to generate Excel documents in Rails 3"
36
36
 
37
37
  if s.respond_to? :specification_version then
38
38
  s.specification_version = 3
@@ -8,7 +8,8 @@ module Spreadsheet
8
8
  download = opts.delete(:force_download)
9
9
  filename = opts.delete(:filename)
10
10
  template_path = opts.delete(:template_path)
11
- workbook = template_path ? Spreadsheet.open(template_path) : Spreadsheet::Workbook.new
11
+ workbook_class = opts.delete(:renderer) || Spreadsheet::Workbook
12
+ workbook = template_path ? Spreadsheet.open(template_path) : workbook_class.new
12
13
  yield(workbook)
13
14
  disposition(download, filename) if (download || filename)
14
15
  workbook
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excel_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
8
  - 3
10
- version: 0.2.3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aditya Sanghi
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-04 00:00:00 Z
18
+ date: 2012-01-27 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Allows you to program spreadsheets using .rxls views
@@ -68,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements: []
69
69
 
70
70
  rubyforge_project:
71
- rubygems_version: 1.8.9
71
+ rubygems_version: 1.8.11
72
72
  signing_key:
73
73
  specification_version: 3
74
74
  summary: Hook rxls to generate Excel documents in Rails 3