excel_rails 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +22 -0
- data/VERSION +1 -1
- data/excel_rails.gemspec +10 -10
- data/lib/excel_rails.rb +2 -1
- 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.
|
1
|
+
0.3.0
|
data/excel_rails.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.
|
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 = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
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 =
|
33
|
-
s.require_paths = [
|
34
|
-
s.rubygems_version =
|
35
|
-
s.summary =
|
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
|
data/lib/excel_rails.rb
CHANGED
@@ -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
|
-
|
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:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 2
|
9
8
|
- 3
|
10
|
-
|
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:
|
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.
|
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
|