roo 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -2
- data/README.txt +25 -11
- data/lib/roo/excel.rb +69 -22
- data/lib/roo/excelx.rb +181 -107
- data/lib/roo/generic_spreadsheet.rb +7 -13
- data/lib/roo/google.rb +3 -23
- data/lib/roo/openoffice.rb +9 -20
- data/lib/roo/version.rb +1 -1
- data/test/test_helper.rb +14 -8
- data/test/test_roo.rb +355 -227
- data/website/index.html +224 -437
- data/website/index.txt +28 -3
- metadata +2 -2
data/website/index.html
CHANGED
@@ -36,91 +36,50 @@
|
|
36
36
|
<a href="http://rubyforge.org/projects/roo" class="numbers">1.1.0</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
|
-
|
40
|
-
|
41
|
-
<p>This gem allows you to access the content of</p>
|
42
|
-
|
43
|
-
|
44
|
-
<ul>
|
39
|
+
<p>This gem allows you to access the content of</p>
|
40
|
+
<ul>
|
45
41
|
<li>Open-office spreadsheets (.ods)</li>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
<p>Die Programme dieses Projekts sind kostenlos erhältlich und verwendbar.
|
56
|
-
Du kannst jedoch die weitere Entwicklung dieses Projekts mit einer finanziellen
|
57
|
-
Zuwendung unterstützen (ansonsten müßte ich mich verstärkt anderen Projekten
|
58
|
-
widmen, die mehr finanziellen Ertrag einbringen, damit ich auch morgen noch
|
42
|
+
<li>Excel spreadsheets (.xls)</li>
|
43
|
+
<li>Google (online) spreadsheets</li>
|
44
|
+
<li>Excel’s new file format .xlsx</li>
|
45
|
+
</ul>
|
46
|
+
<h2>Supporting this project</h2>
|
47
|
+
<p>Die Programme dieses Projekts sind kostenlos erhältlich und verwendbar. <br />
|
48
|
+
Du kannst jedoch die weitere Entwicklung dieses Projekts mit einer finanziellen <br />
|
49
|
+
Zuwendung unterstützen (ansonsten müßte ich mich verstärkt anderen Projekten<br />
|
50
|
+
widmen, die mehr finanziellen Ertrag einbringen, damit ich auch morgen noch<br />
|
59
51
|
für meine Katzen das Futter kaufen kann :-)).</p>
|
60
|
-
|
61
|
-
|
62
|
-
<p>Am bequemsten kannst du per Paypal an die Email-Adresse thopre@gmail.com
|
63
|
-
bezahlen.
|
52
|
+
<p>Am bequemsten kannst du per Paypal an die Email-Adresse thopre@gmail.com <br />
|
53
|
+
bezahlen. <br />
|
64
54
|
Falls du per Überweisung zahlen willst, frage bitte nach meiner Kontoverbindung!</p>
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
mitgeteilt, werde ich dich nach deinem Namen, soweit aus der Email-Adresse
|
70
|
-
ersichtlich, in der Liste veröffenlichen. Falls etwas anderes gewünscht wird,
|
55
|
+
<p>Ich werde, aufteilt pro Quartal, eine Liste der Spender mit Namen und Betrag, <br />
|
56
|
+
sortiert nach Spendenhöhe hier veröffenlichen. Wenn von dir nichts anderes<br />
|
57
|
+
mitgeteilt, werde ich dich nach deinem Namen, soweit aus der Email-Adresse<br />
|
58
|
+
ersichtlich, in der Liste veröffenlichen. Falls etwas anderes gewünscht wird,<br />
|
71
59
|
z. B. “Firma <span class="caps">ABC</span> GmbH” oder anonym, dann teile mir dies bitte mit!</p>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
<tr>
|
86
|
-
<td>0,00 €</td>
|
87
|
-
<td>Test</td>
|
88
|
-
</tr>
|
89
|
-
</table>
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
<h2>Installing</h2>
|
95
|
-
|
96
|
-
|
60
|
+
<h3>Spender</h3>
|
61
|
+
<h4>April-Juni 2008</h4>
|
62
|
+
<table>
|
63
|
+
<tr>
|
64
|
+
<td>Betrag</td>
|
65
|
+
<td>Name</td>
|
66
|
+
</tr>
|
67
|
+
<tr>
|
68
|
+
<td>0,00 €</td>
|
69
|
+
<td>Test</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
<h2>Installing</h2>
|
97
73
|
<pre syntax="ruby">[sudo] gem install roo</pre>
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
<p>Currently only read-access is implemented.
|
74
|
+
<h2>The basics</h2>
|
75
|
+
<p>Currently only read-access is implemented.<br />
|
103
76
|
Google spreadsheets can be read and written.</p>
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
<p>Supposed you have created this spreadsheet:</p>
|
113
|
-
|
114
|
-
|
115
|
-
<p><img src="Screenshot-spreadsheet3.png"></p>
|
116
|
-
|
117
|
-
|
118
|
-
<p>which includes the amount of work you have done for a customer.</p>
|
119
|
-
|
120
|
-
|
121
|
-
<p>You can now process this spreadsheet with the following sample code.</p>
|
122
|
-
|
123
|
-
|
77
|
+
<p>Please note that the upper left cell of a table is numbered (1,1) or (1,’A’) (not 0,0).</p>
|
78
|
+
<h2>Demonstration of usage</h2>
|
79
|
+
<p>Supposed you have created this spreadsheet:</p>
|
80
|
+
<p><img src="Screenshot-spreadsheet3.png"></p>
|
81
|
+
<p>which includes the amount of work you have done for a customer.</p>
|
82
|
+
<p>You can now process this spreadsheet with the following sample code.</p>
|
124
83
|
<pre>
|
125
84
|
<code>
|
126
85
|
1 require 'rubygems'
|
@@ -139,15 +98,12 @@ Google spreadsheets can be read and written.</p>
|
|
139
98
|
14 comment = oo.cell(line,'F')
|
140
99
|
15 amount = sum * HOURLY_RATE
|
141
100
|
16 if date
|
142
|
-
17 puts "#{date}\t#{sum}\t#{amount}\t#{comment}"
|
101
|
+
17 puts "#{date}\t#{sum}\t#{amount}\t#{comment}"
|
143
102
|
18 end
|
144
103
|
19 end
|
145
104
|
</code>
|
146
105
|
</pre>
|
147
|
-
|
148
|
-
<p>which produces this output</p>
|
149
|
-
|
150
|
-
|
106
|
+
<p>which produces this output</p>
|
151
107
|
<pre>
|
152
108
|
<code>
|
153
109
|
2007-05-07 1.0 123.45 Task 1
|
@@ -161,95 +117,65 @@ Google spreadsheets can be read and written.</p>
|
|
161
117
|
2007-05-15 1.0 123.45 Task 3
|
162
118
|
</code>
|
163
119
|
</pre>
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
<code>
|
169
|
-
<
|
170
|
-
<code>first_row</code> and
|
171
|
-
<code>last_row</code>
|
172
|
-
|
173
|
-
<p>you can change line 8 from</p>
|
174
|
-
|
175
|
-
|
120
|
+
<p>With the methods</p>
|
121
|
+
<p><code>first_column</code>,<br />
|
122
|
+
<code>last_column</code>,<br />
|
123
|
+
<code>first_row</code> and<br />
|
124
|
+
<code>last_row</code></p>
|
125
|
+
<p>you can change line 8 from</p>
|
176
126
|
<pre>
|
177
127
|
<code>
|
178
128
|
4.upto(12) do |line|
|
179
129
|
</code>
|
180
130
|
</pre>
|
181
|
-
|
182
|
-
<p>to</p>
|
183
|
-
|
184
|
-
|
131
|
+
<p>to</p>
|
185
132
|
<pre>
|
186
133
|
<code>
|
187
134
|
4.upto(oo.last_row) do |line|
|
188
135
|
</code>
|
189
136
|
</pre>
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
<p>oo.<strong>celltype</strong>(row,col) returns the type of a cell. Currently these types will be
|
137
|
+
<h3>Cell Types</h3>
|
138
|
+
<p>oo.<strong>celltype</strong>(row,col) returns the type of a cell. Currently these types will be<br />
|
195
139
|
returned:</p>
|
196
|
-
|
197
|
-
|
198
|
-
<ul>
|
140
|
+
<ul>
|
199
141
|
<li>:float</li>
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
142
|
+
<li>:string</li>
|
143
|
+
<li>:date</li>
|
144
|
+
<li>:percentage</li>
|
145
|
+
<li>:formula</li>
|
146
|
+
<li>:time</li>
|
147
|
+
</ul>
|
148
|
+
<p>Numeric values are returned as type :float, the return value is a Ruby Float object (note: integer values like 42 are returned as 42.0 – not as a Fixnum 42 object).</p>
|
149
|
+
<p>String values are returned as type :string and Ruby String object.</p>
|
150
|
+
<p>Date values are returned as type :date and as a Ruby Date object.</p>
|
151
|
+
<p>Percentage are return as type :percentage and as Ruby Float object with the <br />
|
152
|
+
range from 0.0 to 1.0.</p>
|
153
|
+
<p>Formulas are returned as type :formula – the value of the cell is the computed<br />
|
154
|
+
value of this formula. The formula itself can be retrieved with the #formula<br />
|
155
|
+
method.</p>
|
156
|
+
<p>Time values are returned as type :time – the value of the cell are the seconds<br />
|
157
|
+
from midnight a a Fixnum object</p>
|
158
|
+
<h3>Write access</h3>
|
159
|
+
<p>Cells in a google spreadsheet can be read or written.</p>
|
160
|
+
<p>To write to a cell use the method call:</p>
|
217
161
|
<pre>
|
218
162
|
<code>
|
219
163
|
oo.set_value(row, col, value)
|
220
164
|
</code>
|
221
165
|
</pre>
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
<p>oo.<strong>formula?</strong>(row,col) returns true if there is a formula</p>
|
236
|
-
|
237
|
-
|
238
|
-
<p>oo.<strong>formula</strong>(row,col) returns the formula in this cell in a string variable (like ”=<acronym title="[.A1:.M13]">SUM</acronym>”).
|
239
|
-
You can do whatever you want with this expression. Please note that the syntax of
|
240
|
-
formulas might vary between different sort of spreadsheets. There is no conversion
|
241
|
-
of the formula syntax.</p>
|
242
|
-
|
243
|
-
|
244
|
-
<p>If there is no formula in this cell nil is returned.</p>
|
245
|
-
|
246
|
-
|
247
|
-
<p>oo.<strong>cell</strong>(row,col) returns the computed result of the formula (as it was saved in the file, no recalculation is done in this Gem).</p>
|
248
|
-
|
249
|
-
|
250
|
-
<p>oo.<strong>formulas</strong> returns all formulas in the selected spreadsheet in an array like this:</p>
|
251
|
-
|
252
|
-
|
166
|
+
<p>There is an example in the examples folder which illustrates write access.</p>
|
167
|
+
<h3>Formulas</h3>
|
168
|
+
<p>Formulas in Openoffice- and Google-Spreadsheets can be handled.</p>
|
169
|
+
<p>oo.<strong>celltype</strong>(row,col) returns :formula if there is a formula in this cell.</p>
|
170
|
+
<p>oo.<strong>formula?</strong>(row,col) returns true if there is a formula</p>
|
171
|
+
<p>oo.<strong>formula</strong>(row,col) returns the formula in this cell in a string variable (like “=<acronym title="[.A1:.M13]"><span class="caps">SUM</span></acronym>”).<br />
|
172
|
+
You can do whatever you want with this expression. Please note that the syntax of<br />
|
173
|
+
formulas might vary between different sort of spreadsheets. There is no conversion<br />
|
174
|
+
of the formula syntax.<br />
|
175
|
+
<br />
|
176
|
+
If there is no formula in this cell nil is returned.</p>
|
177
|
+
<p>oo.<strong>cell</strong>(row,col) returns the computed result of the formula (as it was saved in the file, no recalculation is done in this Gem).</p>
|
178
|
+
<p>oo.<strong>formulas</strong> returns all formulas in the selected spreadsheet in an array like this:</p>
|
253
179
|
<pre>
|
254
180
|
<code>
|
255
181
|
[[1,2,"=SUM(.A1:.B1)"],
|
@@ -257,316 +183,177 @@ of the formula syntax.</p>
|
|
257
183
|
[1,4,"=COS(.D4)"]]
|
258
184
|
</code>
|
259
185
|
</pre>
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
<h3><span class="caps">YAML</span>-Output</h3>
|
271
|
-
|
272
|
-
|
273
|
-
<p>You can generate <span class="caps">YAML</span>-Output from your spreadsheet data. The method is called:</p>
|
274
|
-
|
275
|
-
|
276
|
-
<p>oo.to_yaml # => produces <span class="caps">YAML</span> output from the entire default spreadsheet
|
277
|
-
oo.to_yaml({“myattribute1” => “myvalue1”, “myattribute2” => “myvalue2”)
|
278
|
-
# => <span class="caps">YAML</span> output with additional attributes
|
186
|
+
<p>Each entry consists of the elements row, col, formula.</p>
|
187
|
+
<p>Note: oo.<strong>cell</strong>(row,col) is the same for ordinary cells and formulas. So you can use the computated value of a formula. If you have to distinguish if a cell is a formula use #<strong>formula</strong>?</p>
|
188
|
+
<p>Please note: formulas in Excel-Spreadsheets cannot be handled (this is another gem, see: "Thanks")</p>
|
189
|
+
<h3><span class="caps">YAML</span>-Output</h3>
|
190
|
+
<p>You can generate <span class="caps">YAML</span>-Output from your spreadsheet data. The method is called:</p>
|
191
|
+
<p>oo.to_yaml # => produces <span class="caps">YAML</span> output from the entire default spreadsheet<br />
|
192
|
+
oo.to_yaml({"myattribute1" => “myvalue1”, “myattribute2” => "myvalue2")<br />
|
193
|
+
# => <span class="caps">YAML</span> output with additional attributes<br />
|
279
194
|
oo.to_yaml({..}, 2,10, 300,10) # => only the rectangle from row 2, column 10 to row 300, column 10 will be returned</p>
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
<p>With the <span class="caps">YAML</span> output you can import your data in a Ruby on Rails application in a manner that spreadsheet data can accessed in a Rails application.</p>
|
286
|
-
|
287
|
-
|
288
|
-
<p>This is not limited to a Rails application – you can also do further evaluations with your data.</p>
|
289
|
-
|
290
|
-
|
291
|
-
<h3><span class="caps">CSV</span>-Output</h3>
|
292
|
-
|
293
|
-
|
294
|
-
<p>You can generate output in csv-format with</p>
|
295
|
-
|
296
|
-
|
195
|
+
<p>If you omit one or more parameters the maximum boundaries of your spreadsheet will be used.</p>
|
196
|
+
<p>With the <span class="caps">YAML</span> output you can import your data in a Ruby on Rails application in a manner that spreadsheet data can accessed in a Rails application.</p>
|
197
|
+
<p>This is not limited to a Rails application – you can also do further evaluations with your data.</p>
|
198
|
+
<h3><span class="caps">CSV</span>-Output</h3>
|
199
|
+
<p>You can generate output in csv-format with</p>
|
297
200
|
<pre>
|
298
201
|
<code>
|
299
202
|
oo.to_csv
|
300
203
|
</code>
|
301
204
|
</pre>
|
302
|
-
|
303
|
-
<p>to write to the standard output or</p>
|
304
|
-
|
305
|
-
|
205
|
+
<p>to write to the standard output or</p>
|
306
206
|
<pre>
|
307
207
|
<code>
|
308
208
|
oo.to_csv("somefile.txt")
|
309
209
|
</code>
|
310
210
|
</pre>
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
<
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
<
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
</
|
350
|
-
<
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
<td>:percentage</td>
|
362
|
-
<td>:percentage</td>
|
363
|
-
</tr>
|
364
|
-
<tr>
|
365
|
-
<td>access</td>
|
366
|
-
<td>read-only</td>
|
367
|
-
<td>read-only</td>
|
368
|
-
<td>read and write</td>
|
369
|
-
<td>read-only</td>
|
370
|
-
</tr>
|
371
|
-
</table>
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
<p>The parseexcel-gem does not support the celltype ‘percentage’ but uses ‘float’ instead. This is not a big deal as you can also use ‘float’ to do calculations with these cells.</p>
|
377
|
-
|
378
|
-
|
379
|
-
<p>Old .sxc OpenOffice files are currently not supported – please load these files and save it as an “OpenDocument Spreadsheet (.ods)”.</p>
|
380
|
-
|
381
|
-
|
382
|
-
<p>Instead of a filename the Google#new method needs the ‘key’ of a Google-Spreadsheet. This key can be copied from the <span class="caps">URL</span> when you display a google spreadsheet with your browser.</p>
|
383
|
-
|
384
|
-
|
385
|
-
<p>If you want to use Google spreadsheets you must either have set the
|
386
|
-
environment variables ‘GOOGLE_MAIL’ and ‘GOOGLE_PASSWORD’ or you pass
|
211
|
+
<p>to write to a file.</p>
|
212
|
+
<h3>Using MS-Excel spreadsheets</h3>
|
213
|
+
<p>You can also access MS-Excel spreadsheat.</p>
|
214
|
+
<p>Replace Openoffice with <br />
|
215
|
+
<pre><br />
|
216
|
+
<code>oo = Excel.new("simple_spreadsheet.xls").</p>
|
217
|
+
<p></code><br />
|
218
|
+
</pre></p>
|
219
|
+
<p>or Google.new() or Excelx.new().</p>
|
220
|
+
<p>All methode are the same for OpenOffice-, Excel- and Google-objects.<br />
|
221
|
+
<strike> The only difference<br />
|
222
|
+
is the setting of the default-worksheet. OpenOffice uses the name of the worksheet whereas Excel needs the index of the worksheet (1,2,3,..).<br />
|
223
|
+
</strike></p>
|
224
|
+
<p>Formulas can only be handled in OpenOffice-, Excel .<span class="caps">XLSX</span> files and Google-spreadsheets.</p>
|
225
|
+
<p>Features in OpenOffice/Excel/Google:</p>
|
226
|
+
<table class="border:1px solid black">
|
227
|
+
<tr>
|
228
|
+
<td>feature</td>
|
229
|
+
<td>Open Office</td>
|
230
|
+
<td>Excel</td>
|
231
|
+
<td>Google</td>
|
232
|
+
<td>Excel .xlsx</td>
|
233
|
+
</tr>
|
234
|
+
<tr>
|
235
|
+
<td>formulas</td>
|
236
|
+
<td>yes</td>
|
237
|
+
<td>no</td>
|
238
|
+
<td>yes</td>
|
239
|
+
<td>yes</td>
|
240
|
+
</tr>
|
241
|
+
<tr>
|
242
|
+
<td>celltype</td>
|
243
|
+
<td>:percentage</td>
|
244
|
+
<td>:float</td>
|
245
|
+
<td>:percentage</td>
|
246
|
+
<td>:percentage</td>
|
247
|
+
</tr>
|
248
|
+
<tr>
|
249
|
+
<td>access</td>
|
250
|
+
<td>read-only</td>
|
251
|
+
<td>read-only</td>
|
252
|
+
<td>read and write</td>
|
253
|
+
<td>read-only</td>
|
254
|
+
</tr>
|
255
|
+
</table>
|
256
|
+
<p>The parseexcel-gem does not support the celltype ‘percentage’ but uses ‘float’ instead. This is not a big deal as you can also use ‘float’ to do calculations with these cells.</p>
|
257
|
+
<p>Old .sxc OpenOffice files are currently not supported – please load these files and save it as an “OpenDocument Spreadsheet (.ods)”.</p>
|
258
|
+
<p>Instead of a filename the Google#new method needs the ‘key’ of a Google-Spreadsheet. This key can be copied from the <span class="caps">URL</span> when you display a google spreadsheet with your browser.</p>
|
259
|
+
<p>If you want to use Google spreadsheets you must either have set the<br />
|
260
|
+
environment variables ‘GOOGLE_MAIL’ and ‘GOOGLE_PASSWORD’ or you pass<br />
|
387
261
|
the Google-name and -password to the Google#new method.</p>
|
388
|
-
|
389
|
-
|
390
|
-
<p>Setting these variables can be done if you add these lines to your
|
262
|
+
<p>Setting these variables can be done if you add these lines to your<br />
|
391
263
|
~/.bashrc (or similar setup file within other shells):</p>
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
<p>The default behavior at opening a spreadsheet with a certain extension has been
|
402
|
-
changed.
|
403
|
-
Say you’re trying to open a spreadsheet file with the extension .xls, which is normally
|
404
|
-
an Excel file
|
405
|
-
with the Openoffice.new() call. This cannot work, if the file is really an excel file – instead
|
264
|
+
export GOOGLE_MAIL=“yourname@gmail.com”
|
265
|
+
export GOOGLE_PASSWORD=“mysecretpassword”
|
266
|
+
<p>This gem does not check if you are allowed to access a specific google spreadsheet. If it’s not your own spreadsheet or you are not allowed to read or wwrite to a spreadsheet the behaviour is not defined (but it will not work ;-) ).</p>
|
267
|
+
<p>The default behavior at opening a spreadsheet with a certain extension has been <br />
|
268
|
+
changed.<br />
|
269
|
+
Say you’re trying to open a spreadsheet file with the extension .xls, which is normally<br />
|
270
|
+
an Excel file <br />
|
271
|
+
with the Openoffice.new() call. This cannot work, if the file is really an excel file – instead <br />
|
406
272
|
you have to open it with the Excel.new() call.</p>
|
407
|
-
|
408
|
-
|
409
|
-
<p>Now you’re getting an exception raised. Before it was was only a warning and the
|
273
|
+
<p>Now you’re getting an exception raised. Before it was was only a warning and the<br />
|
410
274
|
access to this file failed.</p>
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
‘Openoffice.new(‘myfile.xls’, false, :ignore)’.</p>
|
420
|
-
|
421
|
-
|
422
|
-
<p>If you set it to :warning you get a warning if you try to use a spreadsheet file with
|
423
|
-
the ‘false’ extension, but the
|
424
|
-
program will try to handle the file with this class (of course this will fail, if the file
|
275
|
+
<p>Theorectically you can have a file with the extension .xls which is in fact an Openoffice spreadsheet file.</p>
|
276
|
+
<p>It’s possible to open such a file with the Openoffice class, but you have have to<br />
|
277
|
+
override the parameter ‘file_warning’ in the new method: <br />
|
278
|
+
‘Openoffice.new(’myfile.xls’, false, :warning)’ or<br />
|
279
|
+
‘Openoffice.new(’myfile.xls’, false, :ignore)’.</p>
|
280
|
+
<p>If you set it to :warning you get a warning if you try to use a spreadsheet file with <br />
|
281
|
+
the ‘false’ extension, but the <br />
|
282
|
+
program will try to handle the file with this class (of course this will fail, if the file<br />
|
425
283
|
is really of the false type).</p>
|
426
|
-
|
427
|
-
|
428
|
-
<p>If you completely know what you are doing you can also disable the warning with the
|
284
|
+
<p>If you completely know what you are doing you can also disable the warning with the<br />
|
429
285
|
parameter :ignore.</p>
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
You can even read openoffice or excel-spreadsheets from a http-address:
|
436
|
-
<pre>
|
286
|
+
<h3>Accessing Spreadsheet over the Web</h3>
|
287
|
+
<p>You can even read openoffice or excel-spreadsheets from a http-address:<br />
|
288
|
+
<pre><br />
|
437
289
|
<code>oo = Excel.new("http://www.somedomain.com/simple_spreadsheet.xls").
|
438
290
|
oo = Openoffice.new("http://www.somedomain.com/simple_spreadsheet.ods").
|
439
|
-
</code
|
440
|
-
</pre>
|
441
|
-
|
442
|
-
|
443
|
-
<pre>
|
291
|
+
</code><br />
|
292
|
+
</pre></p>
|
293
|
+
<p>or a zipped file:<br />
|
294
|
+
<pre><br />
|
444
295
|
<code>oo = Excel.new("http://www.somedomain.com/simple_spreadsheet.xls.zip",:zip).
|
445
296
|
oo = Openoffice.new("http://www.somedomain.com/simple_spreadsheet.ods.zip",:zip).
|
446
|
-
</code
|
447
|
-
</pre>
|
448
|
-
|
449
|
-
|
450
|
-
<pre>
|
297
|
+
</code><br />
|
298
|
+
</pre></p>
|
299
|
+
<p>after working with a spreadsheet from the web you have to call <br />
|
300
|
+
<pre><br />
|
451
301
|
<code>oo.remove_tmp
|
452
|
-
</code
|
453
|
-
</pre>
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
Calling remove_tmp is not the best solution to clean temporary files – i will
|
302
|
+
</code><br />
|
303
|
+
</pre></p>
|
304
|
+
<p>to delete the temporary local copy of the spreadsheet file. If you don’t call<br />
|
305
|
+
this method you will have subdirectories names ‘oo_xxxxx’ which you can remove manually.<br />
|
306
|
+
Calling remove_tmp is not the best solution to clean temporary files – i will <br />
|
458
307
|
provide a better solution in the next releases.</p>
|
459
|
-
|
460
|
-
|
461
|
-
<h3>Remote Access</h3>
|
462
|
-
|
463
|
-
|
464
|
-
<p>You can even access your spreadsheet data from a remote machine via <span class="caps">SOAP</span>. The examples directory shows a little example how to do this. If you like, you can extend these functions or restrict the access to certain cells.
|
308
|
+
<h3>Remote Access</h3>
|
309
|
+
<p>You can even access your spreadsheet data from a remote machine via <span class="caps">SOAP</span>. The examples directory shows a little example how to do this. If you like, you can extend these functions or restrict the access to certain cells. <br />
|
465
310
|
Remote access with <span class="caps">SOAP</span> is nothing specific to roo, you can do this with every Rub object, but i thought it would nice to give an example what could be done with roo.</p>
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
<
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
<li>use it in any view of your application with ”<%= spreadsheet @rspreadsheet, [“Tabelle”] %><br/>” or one of the following formats</li>
|
478
|
-
</ul>
|
479
|
-
|
480
|
-
|
481
|
-
<p><img src="Roo_Spreadsheets_Rails.png"></p>
|
482
|
-
|
483
|
-
|
484
|
-
<h2>Where is it used?</h2>
|
485
|
-
|
486
|
-
|
487
|
-
<p>How do you use roo? What are you doing with roo?</p>
|
488
|
-
|
489
|
-
|
490
|
-
<ul>
|
311
|
+
<h3>Excel spreadsheets / Openoffice spreadsheets / Google spreadsheets with Ruby on Rails</h3>
|
312
|
+
<p>There is a simple helper method to display a spreadsheet at your application page:</p>
|
313
|
+
<ul>
|
314
|
+
<li>in your controller, add “require ‘roo’” and “@rspreadsheet = Openoffice.new(”numbers1.ods")" or<br />
|
315
|
+
“@rspreadsheet = Openoffice.new(”http://www.somehost.com/data/numbers1.od s")" to get access to your spreadsheet file</li>
|
316
|
+
<li>use it in any view of your application with “<%= spreadsheet @rspreadsheet, [”Tabelle"] %><br/>" or one of the following formats</li>
|
317
|
+
</ul>
|
318
|
+
<p><img src="Roo_Spreadsheets_Rails.png"></p>
|
319
|
+
<h2>Where is it used?</h2>
|
320
|
+
<p>How do you use roo? What are you doing with roo?</p>
|
321
|
+
<ul>
|
491
322
|
<li>The author of this gem uses roo for the generation of weekly reports which are (automatically) sent to his customers (Thomas Preymesser, Homepage: www.thopre.com, Blog: thopre.wordpress.com, email me: thopre@gmail.com)</li>
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
<p><a href="rdoc/index.html">rdoc</a></p>
|
508
|
-
|
509
|
-
|
510
|
-
<h2>Tests and test data</h2>
|
511
|
-
|
512
|
-
|
513
|
-
<p>There are many test files within the test directory. If you don’t want to run unit tests and don’t want the test data you can completely delete the ‘test’ directory within the hierarchy of this gem.</p>
|
514
|
-
|
515
|
-
|
516
|
-
<h2>Feature Requests / Bugs</h2>
|
517
|
-
|
518
|
-
|
519
|
-
<p>Submit Feature Requests and bugs here: <a href="http://rubyforge.org/tracker/?group_id=3729">http://rubyforge.org/tracker/?group_id=3729</a></p>
|
520
|
-
|
521
|
-
|
522
|
-
<h2>Forum</h2>
|
523
|
-
|
524
|
-
|
525
|
-
<p>International Group:
|
323
|
+
</ul>
|
324
|
+
<p>If you have an interesting application where you use roo then write me a short description of your project and i will publish it here (write, if your email-address should be published or not).</p>
|
325
|
+
<p>Or you can write directly in the project wiki at <a href="http://roo.rubyforge.org/wiki/wiki.pl?Who's_Using_Roo">http://roo.rubyforge.org/wiki/wiki.pl?Who’s_Using_Roo</a></p>
|
326
|
+
<p>If you don’t want to publish the details you can also write me an email and state, that it should not be published – i am just curious to hear, where it is used.</p>
|
327
|
+
<h2>Documentation</h2>
|
328
|
+
<p><a href="rdoc/index.html">rdoc</a></p>
|
329
|
+
<h2>Tests and test data</h2>
|
330
|
+
<p>There are many test files within the test directory. If you don’t want to run unit tests and don’t want the test data you can completely delete the ‘test’ directory within the hierarchy of this gem.<br />
|
331
|
+
<br />
|
332
|
+
h2. Feature Requests / Bugs</p>
|
333
|
+
<p>Submit Feature Requests and bugs here: <a href="http://rubyforge.org/tracker/?group_id=3729">http://rubyforge.org/tracker/?group_id=3729</a></p>
|
334
|
+
<h2>Forum</h2>
|
335
|
+
<p>International Group:<br />
|
526
336
|
<a href="http://groups.google.com/group/ruby-roo">http://groups.google.com/group/ruby-roo</a></p>
|
527
|
-
|
528
|
-
|
529
|
-
<p>Deutschsprachige Group:
|
337
|
+
<p>Deutschsprachige Group:<br />
|
530
338
|
<a href="http://groups.google.com/group/ruby-roo-de">http://groups.google.com/group/ruby-roo-de</a></p>
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
543
|
-
|
544
|
-
|
545
|
-
<strike>The trunk repository is <code>svn://rubyforge.org/var/svn/gorank/trunk</code> for anonymous access.</strike>
|
546
|
-
|
547
|
-
<h2>License</h2>
|
548
|
-
|
549
|
-
|
550
|
-
<p>This code is free to use under the terms of Ruby</p>
|
551
|
-
|
552
|
-
|
553
|
-
<h2>Contact</h2>
|
554
|
-
|
555
|
-
|
556
|
-
<p>Comments are welcome. Send an email to <a href="mailto:thopre@gmail.com">Thomas Preymesser</a>.</p>
|
557
|
-
|
558
|
-
|
559
|
-
<h2>Thanks</h2>
|
560
|
-
|
561
|
-
|
562
|
-
<ul>
|
339
|
+
<h2>Wiki</h2>
|
340
|
+
<p><a href="http://roo.rubyforge.org/wiki/wiki.pl">http://roo.rubyforge.org/wiki/wiki.pl</a></p>
|
341
|
+
<h2>How to submit patches</h2>
|
342
|
+
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people’s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
|
343
|
+
<p><strike>The trunk repository is <code>svn://rubyforge.org/var/svn/gorank/trunk</code> for anonymous access.</strike></p>
|
344
|
+
<h2>License</h2>
|
345
|
+
<p>This code is free to use under the terms of Ruby</p>
|
346
|
+
<h2>Contact</h2>
|
347
|
+
<p>Comments are welcome. Send an email to <a href="mailto:thopre@gmail.com">Thomas Preymesser</a>.</p>
|
348
|
+
<h2>Thanks</h2>
|
349
|
+
<ul>
|
563
350
|
<li><a href="http://rubyforge.org/users/nicwilliams/">Dr Nic Williams</a> for his wonderful gem ‘<a href="http://rubyforge.org/projects/newgem/">newgem</a>’ which makes it very convenient to create, manage and publish Ruby gems</li>
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
351
|
+
<li>for the Excel-part the <a href="http://rubyforge.org/projects/spreadsheet/">spreadsheet</a> gem is used. My functions are a convenient wrapper around the functions of this gem</li>
|
352
|
+
<li>Dirk Huth fürs Testen unter Windows</li>
|
353
|
+
<li>Thanks to davecahill for a bug-fix patch within the google part</li>
|
354
|
+
</ul>
|
568
355
|
<p class="coda">
|
569
|
-
<a href="mailto:thopre@gmail.com">Thomas Preymesser</a>,
|
356
|
+
<a href="mailto:thopre@gmail.com">Thomas Preymesser</a>, 18th August 2008<br>
|
570
357
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
571
358
|
</p>
|
572
359
|
</div>
|