roo 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +7 -1
- data/Rakefile +1 -2
- data/base64include.rb +149 -0
- data/examples/roo_soap_client.rb +53 -0
- data/examples/roo_soap_server.rb +29 -0
- data/lib/roo.rb +1 -1
- data/lib/roo/excel.rb +40 -22
- data/lib/roo/openoffice.rb +51 -17
- data/lib/roo/version.rb +2 -2
- data/test/borders.ods +0 -0
- data/test/borders.xls +0 -0
- data/test/formula.ods +0 -0
- data/test/formula.xls +0 -0
- data/test/test_roo.rb +265 -120
- data/website/index.html +55 -12
- data/website/index.txt +38 -10
- data/website/stylesheets/screen.css +2 -1
- metadata +10 -13
- data/lib/roo/spreadsheetparser.rb +0 -92
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>roo</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/roo"; return false'>
|
35
35
|
Get Version
|
36
|
-
<a href="http://rubyforge.org/projects/roo" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/roo" class="numbers">0.5.0</a>
|
37
37
|
</div>
|
38
38
|
<h2>What</h2>
|
39
39
|
|
@@ -137,32 +137,56 @@
|
|
137
137
|
</code>
|
138
138
|
</pre>
|
139
139
|
|
140
|
+
<h3>Cell Types</h3>
|
141
|
+
|
142
|
+
|
143
|
+
<p>oo.<strong>celltype</strong>(row,col) returns the type of a cell. Currently these types will be
|
144
|
+
returned:</p>
|
145
|
+
|
146
|
+
|
147
|
+
<ul>
|
148
|
+
<li>:float</li>
|
149
|
+
<li>:string</li>
|
150
|
+
<li>:date</li>
|
151
|
+
<li>:percentage</li>
|
152
|
+
<li>:formula</li>
|
153
|
+
</ul>
|
154
|
+
|
155
|
+
|
140
156
|
<h3>Formulas</h3>
|
141
157
|
|
142
158
|
|
143
159
|
<p>Formulas in Openoffice-Spreadsheets can be handled.</p>
|
144
160
|
|
145
161
|
|
146
|
-
<p>oo
|
162
|
+
<p>oo.<strong>celltype</strong>(row,col) returns :formula if there is a formula in this cell.</p>
|
147
163
|
|
148
164
|
|
149
|
-
<p>oo
|
165
|
+
<p>oo.<strong>formula?</strong>(row,col) returns true if there is a formula</p>
|
150
166
|
|
151
167
|
|
152
|
-
<p>oo
|
168
|
+
<p>oo.<strong>formula</strong>(row,col) returns the formula in this cell in a string variable (like ”=<acronym title="[.A1:.M13]">SUM</acronym>”). You can do whatever you want with this expression.
|
153
169
|
If there is no formula in this cell nil is returned.</p>
|
154
170
|
|
155
171
|
|
156
|
-
<p>oo
|
172
|
+
<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>
|
173
|
+
|
157
174
|
|
175
|
+
<p>oo.<strong>formulas</strong> returns all formulas in the selected spreadsheet in an array like this:</p>
|
158
176
|
|
159
|
-
<p>oo.formulas returns all formulas in the selected spreadsheet in an array like this:</p>
|
160
177
|
|
178
|
+
<pre>
|
179
|
+
<code>
|
180
|
+
[[1,2,"=SUM(.A1:.B1)"],
|
181
|
+
[1,3,"=SIN(.C3)"],
|
182
|
+
[1,4,"=COS(.D4)"]]
|
183
|
+
</code>
|
184
|
+
</pre>
|
161
185
|
|
162
|
-
<p>Each entry consists of the elements row, col,
|
186
|
+
<p>Each entry consists of the elements row, col, formula.</p>
|
163
187
|
|
164
188
|
|
165
|
-
<p>Note: oo
|
189
|
+
<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>
|
166
190
|
|
167
191
|
|
168
192
|
<p>Please note: formulas in Excel-Spreadsheets cannot be handled (this is another gem, see: “Thanks”)</p>
|
@@ -206,6 +230,9 @@ Replace Openoffice with
|
|
206
230
|
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,..).</p>
|
207
231
|
|
208
232
|
|
233
|
+
<p><span class="caps">EDIT</span>: since the release 0.4.2, default_sheet in Excel-object can be handled with names like the Openoffice-sheet.</p>
|
234
|
+
|
235
|
+
|
209
236
|
<p>Formulas can only be handled in OpenOffice-spreadsheets.</p>
|
210
237
|
|
211
238
|
|
@@ -221,7 +248,7 @@ is the setting of the default-worksheet. OpenOffice uses the name of the workshe
|
|
221
248
|
<tr>
|
222
249
|
<td>default_sheet</td>
|
223
250
|
<td>as name</td>
|
224
|
-
<td>as number</td>
|
251
|
+
<td>as number or name (>=0.4.2)</td>
|
225
252
|
</tr>
|
226
253
|
<tr>
|
227
254
|
<td>formulas</td>
|
@@ -238,7 +265,14 @@ is the setting of the default-worksheet. OpenOffice uses the name of the workshe
|
|
238
265
|
|
239
266
|
|
240
267
|
|
241
|
-
<p>Old .sxc OpenOffice files are currently not supported – please load these files and save as an “OpenDocument Spreadsheet (.ods)”.</p>
|
268
|
+
<p>Old .sxc OpenOffice files are currently not supported – please load these files and save it as an “OpenDocument Spreadsheet (.ods)”.</p>
|
269
|
+
|
270
|
+
|
271
|
+
<h3>Remote Access</h3>
|
272
|
+
|
273
|
+
|
274
|
+
<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.
|
275
|
+
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>
|
242
276
|
|
243
277
|
|
244
278
|
<h2>Where is it used?</h2>
|
@@ -285,6 +319,15 @@ is the setting of the default-worksheet. OpenOffice uses the name of the workshe
|
|
285
319
|
<p><a href="http://roo.rubyforge.org/wiki/wiki.pl">http://roo.rubyforge.org/wiki/wiki.pl</a></p>
|
286
320
|
|
287
321
|
|
322
|
+
<h2>How to submit patches</h2>
|
323
|
+
|
324
|
+
|
325
|
+
<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>
|
326
|
+
|
327
|
+
|
328
|
+
<p>The trunk repository is <code>svn://rubyforge.org/var/svn/gorank/trunk</code> for anonymous access.</p>
|
329
|
+
|
330
|
+
|
288
331
|
<h2>License</h2>
|
289
332
|
|
290
333
|
|
@@ -302,11 +345,11 @@ is the setting of the default-worksheet. OpenOffice uses the name of the workshe
|
|
302
345
|
|
303
346
|
<ul>
|
304
347
|
<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>
|
305
|
-
<li>for the Excel-part the
|
348
|
+
<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>
|
306
349
|
<li>Dirk Huth fürs Testen unter Windows</li>
|
307
350
|
</ul>
|
308
351
|
<p class="coda">
|
309
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
352
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 20th July 2007<br>
|
310
353
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
311
354
|
</p>
|
312
355
|
</div>
|
data/website/index.txt
CHANGED
@@ -87,28 +87,43 @@ to
|
|
87
87
|
</code>
|
88
88
|
</pre>
|
89
89
|
|
90
|
+
h3. Cell Types
|
91
|
+
|
92
|
+
oo.*celltype*(row,col) returns the type of a cell. Currently these types will be
|
93
|
+
returned:
|
94
|
+
|
95
|
+
* :float
|
96
|
+
* :string
|
97
|
+
* :date
|
98
|
+
* :percentage
|
99
|
+
* :formula
|
100
|
+
|
90
101
|
h3. Formulas
|
91
102
|
|
92
103
|
Formulas in Openoffice-Spreadsheets can be handled.
|
93
104
|
|
94
|
-
oo
|
105
|
+
oo.*celltype*(row,col) returns :formula if there is a formula in this cell.
|
95
106
|
|
96
|
-
oo
|
107
|
+
oo.*formula?*(row,col) returns true if there is a formula
|
97
108
|
|
98
|
-
oo
|
109
|
+
oo.*formula*(row,col) returns the formula in this cell in a string variable (like "=SUM([.A1:.M13])"). You can do whatever you want with this expression.
|
99
110
|
If there is no formula in this cell nil is returned.
|
100
111
|
|
101
|
-
oo
|
112
|
+
oo.*cell*(row,col) returns the computed result of the formula (as it was saved in the file, no recalculation is done in this Gem).
|
102
113
|
|
103
|
-
oo
|
114
|
+
oo.*formulas* returns all formulas in the selected spreadsheet in an array like this:
|
104
115
|
|
116
|
+
<pre>
|
117
|
+
<code>
|
105
118
|
[[1,2,"=SUM(.A1:.B1)"],
|
106
119
|
[1,3,"=SIN(.C3)"],
|
107
120
|
[1,4,"=COS(.D4)"]]
|
121
|
+
</code>
|
122
|
+
</pre>
|
108
123
|
|
109
|
-
Each entry consists of the elements row, col,
|
124
|
+
Each entry consists of the elements row, col, formula.
|
110
125
|
|
111
|
-
Note: oo
|
126
|
+
Note: oo.*cell*(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 #*formula*?
|
112
127
|
|
113
128
|
Please note: formulas in Excel-Spreadsheets cannot be handled (this is another gem, see: "Thanks")
|
114
129
|
|
@@ -141,17 +156,24 @@ Replace Openoffice with
|
|
141
156
|
All methode are the same for OpenOffice and Excel-objects. The only difference
|
142
157
|
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,..).
|
143
158
|
|
159
|
+
EDIT: since the release 0.4.2, default_sheet in Excel-object can be handled with names like the Openoffice-sheet.
|
160
|
+
|
144
161
|
Formulas can only be handled in OpenOffice-spreadsheets.
|
145
162
|
|
146
163
|
Features in OpenOffice and Excel:
|
147
164
|
|
148
165
|
table(border:1px solid black).
|
149
166
|
|feature|Open Office|Excel|
|
150
|
-
|default_sheet|as name|as number|
|
167
|
+
|default_sheet|as name|as number or name (>=0.4.2)|
|
151
168
|
|formulas|yes|no|
|
152
169
|
|to_yaml|yes|yes|
|
153
170
|
|
154
|
-
Old .sxc OpenOffice files are currently not supported - please load these files and save as an "OpenDocument Spreadsheet (.ods)".
|
171
|
+
Old .sxc OpenOffice files are currently not supported - please load these files and save it as an "OpenDocument Spreadsheet (.ods)".
|
172
|
+
|
173
|
+
h3. Remote Access
|
174
|
+
|
175
|
+
You can even access your spreadsheet data from a remote machine via SOAP. 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.
|
176
|
+
Remote access with SOAP 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.
|
155
177
|
|
156
178
|
h2. Where is it used?
|
157
179
|
|
@@ -183,6 +205,12 @@ h2. Wiki
|
|
183
205
|
|
184
206
|
"http://roo.rubyforge.org/wiki/wiki.pl":http://roo.rubyforge.org/wiki/wiki.pl
|
185
207
|
|
208
|
+
h2. How to submit patches
|
209
|
+
|
210
|
+
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
211
|
+
|
212
|
+
The trunk repository is <code>svn://rubyforge.org/var/svn/gorank/trunk</code> for anonymous access.
|
213
|
+
|
186
214
|
h2. License
|
187
215
|
|
188
216
|
This code is free to use under the terms of Ruby
|
@@ -194,5 +222,5 @@ Comments are welcome. Send an email to "Thomas Preymesser":mailto:thopre@gmail.c
|
|
194
222
|
h2. Thanks
|
195
223
|
|
196
224
|
* "Dr Nic Williams":http://rubyforge.org/users/nicwilliams/ for his wonderful gem '"newgem":http://rubyforge.org/projects/newgem/' which makes it very convenient to create, manage and publish Ruby gems
|
197
|
-
* for the Excel-part the "spreadsheet
|
225
|
+
* for the Excel-part the "spreadsheet":http://rubyforge.org/projects/spreadsheet/ gem is used. My functions are a convenient wrapper around the functions of this gem
|
198
226
|
* Dirk Huth fürs Testen unter Windows
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: roo
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2007-07-20 00:00:00 +02:00
|
8
8
|
summary: roo can access the contents of OpenOffice-Spreadsheets
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -34,18 +34,24 @@ files:
|
|
34
34
|
- Manifest.txt
|
35
35
|
- README.txt
|
36
36
|
- Rakefile
|
37
|
+
- base64include.rb
|
38
|
+
- examples/roo_soap_server.rb
|
39
|
+
- examples/roo_soap_client.rb
|
37
40
|
- lib/roo.rb
|
38
41
|
- lib/roo/version.rb
|
39
42
|
- lib/roo/openoffice.rb
|
40
43
|
- lib/roo/excel.rb
|
41
44
|
- lib/roo/google.rb
|
42
|
-
- lib/roo/spreadsheetparser.rb
|
43
45
|
- scripts/txt2html
|
44
46
|
- setup.rb
|
45
47
|
- test/test_helper.rb
|
46
48
|
- test/test_roo.rb
|
47
49
|
- test/numbers1.ods
|
48
50
|
- test/numbers1.xls
|
51
|
+
- test/borders.ods
|
52
|
+
- test/borders.xls
|
53
|
+
- test/formula.ods
|
54
|
+
- test/formula.xls
|
49
55
|
- website/index.html
|
50
56
|
- website/index.txt
|
51
57
|
- website/javascripts/rounded_corners_lite.inc.js
|
@@ -77,7 +83,7 @@ dependencies:
|
|
77
83
|
requirements:
|
78
84
|
- - ">="
|
79
85
|
- !ruby/object:Gem::Version
|
80
|
-
version: 0.5.
|
86
|
+
version: 0.5.2
|
81
87
|
version:
|
82
88
|
- !ruby/object:Gem::Dependency
|
83
89
|
name: rubyzip
|
@@ -97,12 +103,3 @@ dependencies:
|
|
97
103
|
- !ruby/object:Gem::Version
|
98
104
|
version: "0.5"
|
99
105
|
version:
|
100
|
-
- !ruby/object:Gem::Dependency
|
101
|
-
name: llip
|
102
|
-
version_requirement:
|
103
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
104
|
-
requirements:
|
105
|
-
- - ">="
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: 0.0.1
|
108
|
-
version:
|
@@ -1,92 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
This is experimental. Please do not use it. IT WILL NOT WORK
|
3
|
-
I don't know if i will extend the work on the evaluation of formulas.
|
4
|
-
You can access all formulas as a string and do whatever you want with this.
|
5
|
-
=end
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
require 'llip'
|
9
|
-
require 'llip/visitable'
|
10
|
-
|
11
|
-
class Formula
|
12
|
-
include LLIP::Visitable
|
13
|
-
|
14
|
-
attr_accessor :name
|
15
|
-
attr_accessor :params
|
16
|
-
end
|
17
|
-
|
18
|
-
class Param
|
19
|
-
include LLIP::Visitable
|
20
|
-
|
21
|
-
attr_accessor :column_name
|
22
|
-
end
|
23
|
-
|
24
|
-
class Visitor
|
25
|
-
def visit_formula(formula)
|
26
|
-
puts " -- " + formula.name
|
27
|
-
formula.params.each { |p| p.accept(self) }
|
28
|
-
end
|
29
|
-
|
30
|
-
def visit_param(param)
|
31
|
-
puts " |-- " + param.column_name
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class SpreadsheetParser < LLIP::Parser
|
36
|
-
letters = ("A".."Z").to_a.join("|")
|
37
|
-
|
38
|
-
token :id, "(#{letters})+"
|
39
|
-
|
40
|
-
token :"(", '\('
|
41
|
-
|
42
|
-
token :")", '\)'
|
43
|
-
|
44
|
-
token :"[", '['
|
45
|
-
token :"]", ']'
|
46
|
-
token :".", '.'
|
47
|
-
|
48
|
-
num = (1..9).to_a.join("|")
|
49
|
-
token :num , "(#{num})(#{num}|0)*"
|
50
|
-
|
51
|
-
token :sep, ":"
|
52
|
-
|
53
|
-
scope :formula
|
54
|
-
|
55
|
-
production :formula do |p|
|
56
|
-
p.token(:id) do |result,scanner,parser|
|
57
|
-
result = Formula.new
|
58
|
-
result.name = scanner.current
|
59
|
-
puts "<"+result.name+">"
|
60
|
-
raise unless scanner.next == :"("
|
61
|
-
raise unless scanner.next == :"["
|
62
|
-
scanner.next
|
63
|
-
result.params = parser.parse_params
|
64
|
-
raise unless scanner.current == :"]"
|
65
|
-
raise unless scanner.current == :")"
|
66
|
-
scanner.next
|
67
|
-
result
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
production :params, :recursive do |p|
|
72
|
-
p.default do |scanner, parser|
|
73
|
-
[]
|
74
|
-
end
|
75
|
-
|
76
|
-
p.token(:id) do |result, scanner, parser|
|
77
|
-
param = Param.new
|
78
|
-
param.column_name = scanner.current.to_s
|
79
|
-
raise unless scanner.next == :"."
|
80
|
-
raise unless scanner.next == :num
|
81
|
-
param.column_name += scanner.current.to_s
|
82
|
-
scanner.next
|
83
|
-
result << param
|
84
|
-
end
|
85
|
-
|
86
|
-
p.token(:sep) do |result,scanner,parser|
|
87
|
-
scanner.next
|
88
|
-
result
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|