acts_as_xlsx 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +0 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +32 -0
- data/LICENSE +22 -0
- data/README.md +95 -0
- data/Rakefile +18 -0
- data/acts_as_xlsx.gemspec +38 -0
- data/doc/Axlsx.html +124 -0
- data/doc/Axlsx/Ar.html +199 -0
- data/doc/Axlsx/Ar/ClassMethods.html +259 -0
- data/doc/Axlsx/Ar/InstanceMethods.html +188 -0
- data/doc/Axlsx/Ar/SingletonMethods.html +348 -0
- data/doc/_index.html +146 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file.LICENSE.html +86 -0
- data/doc/file.README.html +166 -0
- data/doc/file_list.html +52 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +166 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +167 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +70 -0
- data/doc/top-level-namespace.html +103 -0
- data/lib/axlsx/acts_as_xlsx.rb +87 -0
- data/test/acts_as_xlsx.sqlite3.db +0 -0
- data/test/database.yml +3 -0
- data/test/helper.rb +72 -0
- data/test/tc_acts_as_xlsx.rb +49 -0
- metadata +157 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: Axlsx::Ar::ClassMethods
|
8
|
+
|
9
|
+
— Acts As Xlsx (Axlsx)
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '../..';
|
19
|
+
if (relpath != '') relpath += '/';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
25
|
+
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="../../_index.html">Index (C)</a> »
|
37
|
+
<span class='title'><span class='object_link'><a href="../../Axlsx.html" title="Axlsx (module)">Axlsx</a></span></span> » <span class='title'><span class='object_link'><a href="../Ar.html" title="Axlsx::Ar (module)">Ar</a></span></span>
|
38
|
+
»
|
39
|
+
<span class="title">ClassMethods</span>
|
40
|
+
|
41
|
+
|
42
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div id="search">
|
46
|
+
|
47
|
+
<a id="class_list_link" href="#">Class List</a>
|
48
|
+
|
49
|
+
<a id="method_list_link" href="#">Method List</a>
|
50
|
+
|
51
|
+
<a id="file_list_link" href="#">File List</a>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
<div class="clear"></div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<iframe id="search_frame"></iframe>
|
58
|
+
|
59
|
+
<div id="content"><h1>Module: Axlsx::Ar::ClassMethods
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
<dt class="r1 last">Defined in:</dt>
|
75
|
+
<dd class="r1 last">lib/axlsx/acts_as_xlsx.rb</dd>
|
76
|
+
|
77
|
+
</dl>
|
78
|
+
<div class="clear"></div>
|
79
|
+
|
80
|
+
<h2>Overview</h2><div class="docstring">
|
81
|
+
<div class="discussion">
|
82
|
+
|
83
|
+
<p>Class methods for the mixin</p>
|
84
|
+
|
85
|
+
|
86
|
+
</div>
|
87
|
+
</div>
|
88
|
+
<div class="tags">
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<h2>
|
98
|
+
Instance Method Summary
|
99
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
100
|
+
</h2>
|
101
|
+
|
102
|
+
<ul class="summary">
|
103
|
+
|
104
|
+
<li class="public ">
|
105
|
+
<span class="summary_signature">
|
106
|
+
|
107
|
+
<a href="#acts_as_xlsx-instance_method" title="#acts_as_xlsx (instance method)">- (Object) <strong>acts_as_xlsx</strong>(options = {}) </a>
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
</span>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<span class="summary_desc"><div class='inline'>
|
121
|
+
<p>defines the class method to inject to_xlsx.</p>
|
122
|
+
</div></span>
|
123
|
+
|
124
|
+
</li>
|
125
|
+
|
126
|
+
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
<div id="instance_method_details" class="method_details_list">
|
133
|
+
<h2>Instance Method Details</h2>
|
134
|
+
|
135
|
+
|
136
|
+
<div class="method_details first">
|
137
|
+
<p class="signature first" id="acts_as_xlsx-instance_method">
|
138
|
+
|
139
|
+
- (<tt>Object</tt>) <strong>acts_as_xlsx</strong>(options = {})
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
</p><div class="docstring">
|
144
|
+
<div class="discussion">
|
145
|
+
|
146
|
+
<p>defines the class method to inject to_xlsx</p>
|
147
|
+
|
148
|
+
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
<div class="tags">
|
152
|
+
|
153
|
+
<div class="examples">
|
154
|
+
<h3>Examples:</h3>
|
155
|
+
|
156
|
+
<h4><div class='inline'></div></h4>
|
157
|
+
<pre class="example code">class MyModel < ActiveRecord::Base
|
158
|
+
acts_as_xlsx :columns=> [:id, :created_at, :updated_at], :i18n => 'activerecord.attributes'</pre>
|
159
|
+
|
160
|
+
</div>
|
161
|
+
<h3>Parameters:</h3>
|
162
|
+
<ul class="param">
|
163
|
+
|
164
|
+
<li>
|
165
|
+
|
166
|
+
<span class='name'>options</span>
|
167
|
+
|
168
|
+
|
169
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
170
|
+
|
171
|
+
|
172
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
173
|
+
|
174
|
+
|
175
|
+
—
|
176
|
+
<div class='inline'>
|
177
|
+
<p>a customizable set of options</p>
|
178
|
+
</div>
|
179
|
+
|
180
|
+
</li>
|
181
|
+
|
182
|
+
</ul>
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
<h3>Options Hash (<tt>options</tt>):</h3>
|
188
|
+
<ul class="option">
|
189
|
+
|
190
|
+
<li>
|
191
|
+
<span class="name">columns</span>
|
192
|
+
<span class="type">(<tt>Array</tt>, <tt>Symbol</tt>)</span>
|
193
|
+
<span class="default">
|
194
|
+
|
195
|
+
</span>
|
196
|
+
— <div class='inline'>
|
197
|
+
<p>an array of symbols defining the columns and methods to call in generating
|
198
|
+
sheet data for each row.</p>
|
199
|
+
</div>
|
200
|
+
</li>
|
201
|
+
|
202
|
+
<li>
|
203
|
+
<span class="name">i18n</span>
|
204
|
+
<span class="type">(<tt>String</tt>)</span>
|
205
|
+
<span class="default">
|
206
|
+
|
207
|
+
— default:
|
208
|
+
<tt>default nil</tt>
|
209
|
+
|
210
|
+
</span>
|
211
|
+
— <div class='inline'>
|
212
|
+
<p>The path to search for localization. When this is specified your i18n.t
|
213
|
+
will be used to determine the labels for columns.</p>
|
214
|
+
</div>
|
215
|
+
</li>
|
216
|
+
|
217
|
+
</ul>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
</div><table class="source_code">
|
222
|
+
<tr>
|
223
|
+
<td>
|
224
|
+
<pre class="lines">
|
225
|
+
|
226
|
+
|
227
|
+
27
|
228
|
+
28
|
229
|
+
29
|
230
|
+
30
|
231
|
+
31
|
232
|
+
32</pre>
|
233
|
+
</td>
|
234
|
+
<td>
|
235
|
+
<pre class="code"><span class="info file"># File 'lib/axlsx/acts_as_xlsx.rb', line 27</span>
|
236
|
+
|
237
|
+
<span class='kw'>def</span> <span class='id acts_as_xlsx'>acts_as_xlsx</span><span class='lparen'>(</span><span class='id options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
238
|
+
<span class='id cattr_accessor'>cattr_accessor</span> <span class='symbol'>:xlsx_i18n</span><span class='comma'>,</span> <span class='symbol'>:xlsx_columns</span>
|
239
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id xlsx_i18n'>xlsx_i18n</span> <span class='op'>=</span> <span class='id options'>options</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:i18n</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>false</span>
|
240
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id xlsx_columns'>xlsx_columns</span> <span class='op'>=</span> <span class='id options'>options</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:columns</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id column_names'>column_names</span><span class='period'>.</span><span class='id map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id c'>c</span><span class='op'>|</span> <span class='id c'>c</span> <span class='op'>=</span> <span class='id c'>c</span><span class='period'>.</span><span class='id to_sym'>to_sym</span> <span class='rbrace'>}</span>
|
241
|
+
<span class='id extend'>extend</span> <span class='const'>Axlsx</span><span class='op'>::</span><span class='const'>Ar</span><span class='op'>::</span><span class='const'>SingletonMethods</span>
|
242
|
+
<span class='kw'>end</span></pre>
|
243
|
+
</td>
|
244
|
+
</tr>
|
245
|
+
</table>
|
246
|
+
</div>
|
247
|
+
|
248
|
+
</div>
|
249
|
+
|
250
|
+
</div>
|
251
|
+
|
252
|
+
<div id="footer">
|
253
|
+
Generated on Thu Dec 1 00:04:39 2011 by
|
254
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
255
|
+
0.7.3 (ruby-1.9.3).
|
256
|
+
</div>
|
257
|
+
|
258
|
+
</body>
|
259
|
+
</html>
|
@@ -0,0 +1,188 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: Axlsx::Ar::InstanceMethods
|
8
|
+
|
9
|
+
— Acts As Xlsx (Axlsx)
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '../..';
|
19
|
+
if (relpath != '') relpath += '/';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
25
|
+
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="../../_index.html">Index (I)</a> »
|
37
|
+
<span class='title'><span class='object_link'><a href="../../Axlsx.html" title="Axlsx (module)">Axlsx</a></span></span> » <span class='title'><span class='object_link'><a href="../Ar.html" title="Axlsx::Ar (module)">Ar</a></span></span>
|
38
|
+
»
|
39
|
+
<span class="title">InstanceMethods</span>
|
40
|
+
|
41
|
+
|
42
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div id="search">
|
46
|
+
|
47
|
+
<a id="class_list_link" href="#">Class List</a>
|
48
|
+
|
49
|
+
<a id="method_list_link" href="#">Method List</a>
|
50
|
+
|
51
|
+
<a id="file_list_link" href="#">File List</a>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
<div class="clear"></div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<iframe id="search_frame"></iframe>
|
58
|
+
|
59
|
+
<div id="content"><h1>Module: Axlsx::Ar::InstanceMethods
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
<dt class="r1 last">Defined in:</dt>
|
75
|
+
<dd class="r1 last">lib/axlsx/acts_as_xlsx.rb</dd>
|
76
|
+
|
77
|
+
</dl>
|
78
|
+
<div class="clear"></div>
|
79
|
+
|
80
|
+
<h2>Overview</h2><div class="docstring">
|
81
|
+
<div class="discussion">
|
82
|
+
|
83
|
+
<p>Defines the instance methods we add to ActiveRecord::Base</p>
|
84
|
+
|
85
|
+
|
86
|
+
</div>
|
87
|
+
</div>
|
88
|
+
<div class="tags">
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<h2>
|
98
|
+
Instance Method Summary
|
99
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
100
|
+
</h2>
|
101
|
+
|
102
|
+
<ul class="summary">
|
103
|
+
|
104
|
+
<li class="public ">
|
105
|
+
<span class="summary_signature">
|
106
|
+
|
107
|
+
<a href="#to_xlsx-instance_method" title="#to_xlsx (instance method)">- (Object) <strong>to_xlsx</strong>(options = {}) </a>
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
</span>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<span class="summary_desc"><div class='inline'>
|
121
|
+
<p>Allows a single instance to be exported All active record find options are
|
122
|
+
allowed.</p>
|
123
|
+
</div></span>
|
124
|
+
|
125
|
+
</li>
|
126
|
+
|
127
|
+
|
128
|
+
</ul>
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<div id="instance_method_details" class="method_details_list">
|
134
|
+
<h2>Instance Method Details</h2>
|
135
|
+
|
136
|
+
|
137
|
+
<div class="method_details first">
|
138
|
+
<p class="signature first" id="to_xlsx-instance_method">
|
139
|
+
|
140
|
+
- (<tt>Object</tt>) <strong>to_xlsx</strong>(options = {})
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
</p><div class="docstring">
|
145
|
+
<div class="discussion">
|
146
|
+
|
147
|
+
<p>Allows a single instance to be exported All active record find options are
|
148
|
+
allowed</p>
|
149
|
+
|
150
|
+
|
151
|
+
</div>
|
152
|
+
</div>
|
153
|
+
<div class="tags">
|
154
|
+
|
155
|
+
|
156
|
+
</div><table class="source_code">
|
157
|
+
<tr>
|
158
|
+
<td>
|
159
|
+
<pre class="lines">
|
160
|
+
|
161
|
+
|
162
|
+
88
|
163
|
+
89
|
164
|
+
90</pre>
|
165
|
+
</td>
|
166
|
+
<td>
|
167
|
+
<pre class="code"><span class="info file"># File 'lib/axlsx/acts_as_xlsx.rb', line 88</span>
|
168
|
+
|
169
|
+
<span class='kw'>def</span> <span class='id to_xlsx'>to_xlsx</span><span class='lparen'>(</span><span class='id options'>options</span><span class='op'>=</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
170
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id class'>class</span><span class='period'>.</span><span class='id to_xlsx'>to_xlsx</span><span class='lparen'>(</span><span class='kw'>self</span><span class='period'>.</span><span class='id id'>id</span><span class='comma'>,</span> <span class='id options'>options</span><span class='rparen'>)</span>
|
171
|
+
<span class='kw'>end</span></pre>
|
172
|
+
</td>
|
173
|
+
</tr>
|
174
|
+
</table>
|
175
|
+
</div>
|
176
|
+
|
177
|
+
</div>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
|
181
|
+
<div id="footer">
|
182
|
+
Generated on Wed Nov 30 22:59:02 2011 by
|
183
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
184
|
+
0.7.3 (ruby-1.9.3).
|
185
|
+
</div>
|
186
|
+
|
187
|
+
</body>
|
188
|
+
</html>
|
@@ -0,0 +1,348 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Module: Axlsx::Ar::SingletonMethods
|
8
|
+
|
9
|
+
— Acts As Xlsx (Axlsx)
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
relpath = '../..';
|
19
|
+
if (relpath != '') relpath += '/';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
25
|
+
|
26
|
+
|
27
|
+
</head>
|
28
|
+
<body>
|
29
|
+
<script type="text/javascript" charset="utf-8">
|
30
|
+
if (window.top.frames.main) document.body.className = 'frames';
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<div id="header">
|
34
|
+
<div id="menu">
|
35
|
+
|
36
|
+
<a href="../../_index.html">Index (S)</a> »
|
37
|
+
<span class='title'><span class='object_link'><a href="../../Axlsx.html" title="Axlsx (module)">Axlsx</a></span></span> » <span class='title'><span class='object_link'><a href="../Ar.html" title="Axlsx::Ar (module)">Ar</a></span></span>
|
38
|
+
»
|
39
|
+
<span class="title">SingletonMethods</span>
|
40
|
+
|
41
|
+
|
42
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div id="search">
|
46
|
+
|
47
|
+
<a id="class_list_link" href="#">Class List</a>
|
48
|
+
|
49
|
+
<a id="method_list_link" href="#">Method List</a>
|
50
|
+
|
51
|
+
<a id="file_list_link" href="#">File List</a>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
<div class="clear"></div>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<iframe id="search_frame"></iframe>
|
58
|
+
|
59
|
+
<div id="content"><h1>Module: Axlsx::Ar::SingletonMethods
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
</h1>
|
64
|
+
|
65
|
+
<dl class="box">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
<dt class="r1 last">Defined in:</dt>
|
75
|
+
<dd class="r1 last">lib/axlsx/acts_as_xlsx.rb</dd>
|
76
|
+
|
77
|
+
</dl>
|
78
|
+
<div class="clear"></div>
|
79
|
+
|
80
|
+
<h2>Overview</h2><div class="docstring">
|
81
|
+
<div class="discussion">
|
82
|
+
|
83
|
+
<p>Singleton methods for the mixin</p>
|
84
|
+
|
85
|
+
|
86
|
+
</div>
|
87
|
+
</div>
|
88
|
+
<div class="tags">
|
89
|
+
|
90
|
+
|
91
|
+
</div>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<h2>
|
98
|
+
Instance Method Summary
|
99
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
100
|
+
</h2>
|
101
|
+
|
102
|
+
<ul class="summary">
|
103
|
+
|
104
|
+
<li class="public ">
|
105
|
+
<span class="summary_signature">
|
106
|
+
|
107
|
+
<a href="#to_xlsx-instance_method" title="#to_xlsx (instance method)">- (Object) <strong>to_xlsx</strong>(options = {}) </a>
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
</span>
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
<span class="summary_desc"><div class='inline'>
|
121
|
+
<p>Maps the AR class to an Axlsx package options are passed into AR find.</p>
|
122
|
+
</div></span>
|
123
|
+
|
124
|
+
</li>
|
125
|
+
|
126
|
+
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
<div id="instance_method_details" class="method_details_list">
|
133
|
+
<h2>Instance Method Details</h2>
|
134
|
+
|
135
|
+
|
136
|
+
<div class="method_details first">
|
137
|
+
<p class="signature first" id="to_xlsx-instance_method">
|
138
|
+
|
139
|
+
- (<tt>Object</tt>) <strong>to_xlsx</strong>(options = {})
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
</p><div class="docstring">
|
144
|
+
<div class="discussion">
|
145
|
+
|
146
|
+
<p>Maps the AR class to an Axlsx package options are passed into AR find</p>
|
147
|
+
|
148
|
+
|
149
|
+
</div>
|
150
|
+
</div>
|
151
|
+
<div class="tags">
|
152
|
+
<h3>Parameters:</h3>
|
153
|
+
<ul class="param">
|
154
|
+
|
155
|
+
<li>
|
156
|
+
|
157
|
+
<span class='name'>columns</span>
|
158
|
+
|
159
|
+
|
160
|
+
<span class='type'>(<tt>Array</tt>, <tt>Array</tt>)</span>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
—
|
165
|
+
<div class='inline'>
|
166
|
+
<p>as an array of symbols or a symbol that defines the attributes or methods
|
167
|
+
to render in the sheet.</p>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
</li>
|
171
|
+
|
172
|
+
<li>
|
173
|
+
|
174
|
+
<span class='name'>options</span>
|
175
|
+
|
176
|
+
|
177
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
178
|
+
|
179
|
+
|
180
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
181
|
+
|
182
|
+
|
183
|
+
—
|
184
|
+
<div class='inline'>
|
185
|
+
<p>a customizable set of options</p>
|
186
|
+
</div>
|
187
|
+
|
188
|
+
</li>
|
189
|
+
|
190
|
+
</ul>
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<h3>Options Hash (<tt>options</tt>):</h3>
|
196
|
+
<ul class="option">
|
197
|
+
|
198
|
+
<li>
|
199
|
+
<span class="name">header_style</span>
|
200
|
+
<span class="type">(<tt>Integer</tt>)</span>
|
201
|
+
<span class="default">
|
202
|
+
|
203
|
+
</span>
|
204
|
+
— <div class='inline'>
|
205
|
+
<p>to apply to the first row of field names</p>
|
206
|
+
</div>
|
207
|
+
</li>
|
208
|
+
|
209
|
+
<li>
|
210
|
+
<span class="name">an</span>
|
211
|
+
<span class="type">(<tt>Array</tt>, <tt>Symbol</tt>)</span>
|
212
|
+
<span class="default">
|
213
|
+
|
214
|
+
</span>
|
215
|
+
— <div class='inline'>
|
216
|
+
<p>array of Axlsx types for each cell in data rows or a single type that will
|
217
|
+
be applied to all types.</p>
|
218
|
+
</div>
|
219
|
+
</li>
|
220
|
+
|
221
|
+
<li>
|
222
|
+
<span class="name">style</span>
|
223
|
+
<span class="type">(<tt>Integer</tt>, <tt>Array</tt>)</span>
|
224
|
+
<span class="default">
|
225
|
+
|
226
|
+
</span>
|
227
|
+
— <div class='inline'>
|
228
|
+
<p>The style to pass to Worksheet#add_row</p>
|
229
|
+
</div>
|
230
|
+
</li>
|
231
|
+
|
232
|
+
<li>
|
233
|
+
<span class="name">i18n</span>
|
234
|
+
<span class="type">(<tt>String</tt>)</span>
|
235
|
+
<span class="default">
|
236
|
+
|
237
|
+
</span>
|
238
|
+
— <div class='inline'>
|
239
|
+
<p>The path to i18n attributes. (usually activerecord.attributes)</p>
|
240
|
+
</div>
|
241
|
+
</li>
|
242
|
+
|
243
|
+
</ul>
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
<h3>See Also:</h3>
|
248
|
+
<ul class="see">
|
249
|
+
|
250
|
+
<li>Worksheet#add_row</li>
|
251
|
+
|
252
|
+
</ul>
|
253
|
+
|
254
|
+
</div><table class="source_code">
|
255
|
+
<tr>
|
256
|
+
<td>
|
257
|
+
<pre class="lines">
|
258
|
+
|
259
|
+
|
260
|
+
46
|
261
|
+
47
|
262
|
+
48
|
263
|
+
49
|
264
|
+
50
|
265
|
+
51
|
266
|
+
52
|
267
|
+
53
|
268
|
+
54
|
269
|
+
55
|
270
|
+
56
|
271
|
+
57
|
272
|
+
58
|
273
|
+
59
|
274
|
+
60
|
275
|
+
61
|
276
|
+
62
|
277
|
+
63
|
278
|
+
64
|
279
|
+
65
|
280
|
+
66
|
281
|
+
67
|
282
|
+
68
|
283
|
+
69
|
284
|
+
70
|
285
|
+
71
|
286
|
+
72
|
287
|
+
73
|
288
|
+
74
|
289
|
+
75
|
290
|
+
76
|
291
|
+
77
|
292
|
+
78
|
293
|
+
79</pre>
|
294
|
+
</td>
|
295
|
+
<td>
|
296
|
+
<pre class="code"><span class="info file"># File 'lib/axlsx/acts_as_xlsx.rb', line 46</span>
|
297
|
+
|
298
|
+
<span class='kw'>def</span> <span class='id to_xlsx'>to_xlsx</span><span class='lparen'>(</span><span class='id options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
299
|
+
|
300
|
+
<span class='id row_style'>row_style</span> <span class='op'>=</span> <span class='id options'>options</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:style</span><span class='rparen'>)</span>
|
301
|
+
<span class='id header_style'>header_style</span> <span class='op'>=</span> <span class='id options'>options</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:header_style</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id row_style'>row_style</span>
|
302
|
+
<span class='id types'>types</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id options'>options</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:types</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id flatten'>flatten</span>
|
303
|
+
|
304
|
+
<span class='id i18n'>i18n</span> <span class='op'>=</span> <span class='id options'>options</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:i18n</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id xlsx_i18n'>xlsx_i18n</span>
|
305
|
+
<span class='id columns'>columns</span> <span class='op'>=</span> <span class='id options'>options</span><span class='period'>.</span><span class='id delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:columns</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='kw'>self</span><span class='period'>.</span><span class='id xlsx_columns'>xlsx_columns</span>
|
306
|
+
|
307
|
+
<span class='id p'>p</span> <span class='op'>=</span> <span class='const'>Package</span><span class='period'>.</span><span class='id new'>new</span>
|
308
|
+
<span class='id row_style'>row_style</span> <span class='op'>=</span> <span class='id p'>p</span><span class='period'>.</span><span class='id workbook'>workbook</span><span class='period'>.</span><span class='id styles'>styles</span><span class='period'>.</span><span class='id add_style'>add_style</span><span class='lparen'>(</span><span class='id row_style'>row_style</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id row_style'>row_style</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
309
|
+
<span class='id header_style'>header_style</span> <span class='op'>=</span> <span class='id p'>p</span><span class='period'>.</span><span class='id workbook'>workbook</span><span class='period'>.</span><span class='id styles'>styles</span><span class='period'>.</span><span class='id add_style'>add_style</span><span class='lparen'>(</span><span class='id header_style'>header_style</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id header_style'>header_style</span><span class='period'>.</span><span class='id nil?'>nil?</span>
|
310
|
+
|
311
|
+
<span class='id data'>data</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='op'>*</span><span class='id find'>find</span><span class='lparen'>(</span><span class='symbol'>:all</span><span class='comma'>,</span> <span class='id options'>options</span><span class='rparen'>)</span><span class='rbracket'>]</span>
|
312
|
+
<span class='id data'>data</span><span class='period'>.</span><span class='id compact!'>compact!</span>
|
313
|
+
<span class='id data'>data</span><span class='period'>.</span><span class='id flatten!'>flatten!</span>
|
314
|
+
|
315
|
+
<span class='kw'>return</span> <span class='id p'>p</span> <span class='kw'>if</span> <span class='id data'>data</span><span class='period'>.</span><span class='id empty?'>empty?</span>
|
316
|
+
<span class='id p'>p</span><span class='period'>.</span><span class='id workbook'>workbook</span><span class='period'>.</span><span class='id add_worksheet'>add_worksheet</span><span class='lparen'>(</span><span class='symbol'>:name</span><span class='op'>=></span><span class='id table_name'>table_name</span><span class='period'>.</span><span class='id humanize'>humanize</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id sheet'>sheet</span><span class='op'>|</span>
|
317
|
+
|
318
|
+
<span class='id col_labels'>col_labels</span> <span class='op'>=</span> <span class='kw'>if</span> <span class='id i18n'>i18n</span>
|
319
|
+
<span class='id columns'>columns</span><span class='period'>.</span><span class='id map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id c'>c</span><span class='op'>|</span> <span class='const'>I18n</span><span class='period'>.</span><span class='id t'>t</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id i18n'>i18n</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='period'>.</span><span class='id name'>name</span><span class='period'>.</span><span class='id underscore'>underscore</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id c'>c</span><span class='rbrace'>}</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
320
|
+
<span class='kw'>else</span>
|
321
|
+
<span class='id columns'>columns</span><span class='period'>.</span><span class='id map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id c'>c</span><span class='op'>|</span> <span class='id c'>c</span><span class='period'>.</span><span class='id to_s'>to_s</span><span class='period'>.</span><span class='id humanize'>humanize</span> <span class='rbrace'>}</span>
|
322
|
+
<span class='kw'>end</span>
|
323
|
+
|
324
|
+
<span class='id sheet'>sheet</span><span class='period'>.</span><span class='id add_row'>add_row</span> <span class='id col_labels'>col_labels</span><span class='comma'>,</span> <span class='symbol'>:style</span><span class='op'>=></span><span class='id header_style'>header_style</span>
|
325
|
+
|
326
|
+
<span class='id data'>data</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id r'>r</span><span class='op'>|</span>
|
327
|
+
<span class='id sheet'>sheet</span><span class='period'>.</span><span class='id add_row'>add_row</span> <span class='id columns'>columns</span><span class='period'>.</span><span class='id map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id c'>c</span><span class='op'>|</span> <span class='id r'>r</span><span class='period'>.</span><span class='id send'>send</span><span class='lparen'>(</span><span class='id c'>c</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:style</span><span class='op'>=></span><span class='id row_style'>row_style</span><span class='comma'>,</span> <span class='symbol'>:types</span><span class='op'>=></span><span class='id types'>types</span>
|
328
|
+
<span class='kw'>end</span>
|
329
|
+
<span class='kw'>end</span>
|
330
|
+
<span class='id p'>p</span>
|
331
|
+
<span class='kw'>end</span></pre>
|
332
|
+
</td>
|
333
|
+
</tr>
|
334
|
+
</table>
|
335
|
+
</div>
|
336
|
+
|
337
|
+
</div>
|
338
|
+
|
339
|
+
</div>
|
340
|
+
|
341
|
+
<div id="footer">
|
342
|
+
Generated on Thu Dec 1 00:04:39 2011 by
|
343
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
344
|
+
0.7.3 (ruby-1.9.3).
|
345
|
+
</div>
|
346
|
+
|
347
|
+
</body>
|
348
|
+
</html>
|