roo 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.6.1 2007-10-06
2
+ * 2 enhancements:
3
+ * Openoffice: percentage-values are now treated as numbers (not strings)
4
+ * Openoffice: refactoring
5
+ * 1 bugfix
6
+ * Openoffice: repeating date-values in a line are now handled correctly
1
7
  == 0.6.0 2007-10-06
2
8
  * 1 enhancement:
3
9
  * csv-output to stdout or file
@@ -425,16 +425,17 @@ private
425
425
  def belegen(x,y,i,v,vt,formula,tr,str_v)
426
426
  @cell_type["#{y},#{x+i}"] = Openoffice.oo_type_2_roo_type(vt)
427
427
  @formula["#{y},#{x+i}"] = formula if formula
428
- if @cell_type["#{y},#{x+i}"] == :float
428
+ case @cell_type["#{y},#{x+i}"]
429
+ when :float
429
430
  @cell["#{y},#{x+i}"] = v.to_f
430
- elsif @cell_type["#{y},#{x+i}"] == :string
431
+ when :string
431
432
  @cell["#{y},#{x+i}"] = str_v
432
- elsif @cell_type["#{y},#{x}"] == :date
433
- @cell["#{y},#{x}"] = tr.attributes['date-value']
434
- elsif @cell_type["#{y},#{x+i}"] == :percentage
435
- @cell["#{y},#{x+i}"] = v
433
+ when :date
434
+ @cell["#{y},#{x+i}"] = tr.attributes['date-value']
435
+ when :percentage
436
+ @cell["#{y},#{x+i}"] = v.to_f
436
437
  else
437
- @cell["#{y},#{x}"] = v
438
+ @cell["#{y},#{x+i}"] = v
438
439
  end
439
440
  end
440
441
 
@@ -499,7 +500,7 @@ private
499
500
  end
500
501
  end
501
502
  if skip
502
- if v != nil
503
+ if v != nil or tr.attributes['date-value']
503
504
  0.upto(skip.to_i-1) do |i|
504
505
  belegen(x,y,i,v,vt,formula,tr,str_v)
505
506
  end
data/lib/roo/version.rb CHANGED
@@ -2,7 +2,7 @@ module Roo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 6
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/test/numbers1.ods CHANGED
Binary file
data/test/numbers1.xls CHANGED
Binary file
data/test/test_roo.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # damit keine falschen Vermutungen aufkommen: Ich habe religoes rein gar nichts
2
+ # mit diesem Bibelbund zu tun, aber die hatten eine ziemlich grosse
3
+ # Spreadsheet-Datei oeffentlich im Netz, die sich ganz gut zum Testen eignete.
4
+ #
1
5
  require File.dirname(__FILE__) + '/test_helper.rb'
2
6
  #require 'soap/rpc/driver'
3
7
  require 'fileutils'
@@ -713,31 +717,98 @@ class TestRoo < Test::Unit::TestCase
713
717
  oo = Openoffice.new(File.join("test","simple_spreadsheet_from_italo.ods"))
714
718
  oo.default_sheet = oo.sheets.first
715
719
 
716
- after Date.new(2007,10,1) do
717
- assert_equal '1', oo.cell('A',1)
718
- assert_equal '1', oo.cell('B',1)
719
- assert_equal '1', oo.cell('C',1)
720
-
721
- # assert_equal 1, oo.cell('A',2)
722
- # assert_equal 2, oo.cell('B',2)
723
- # assert_equal 1, oo.cell('C',2)
724
- # are stored as strings, not numbers
720
+ assert_equal '1', oo.cell('A',1)
721
+ assert_equal '1', oo.cell('B',1)
722
+ assert_equal '1', oo.cell('C',1)
723
+
724
+ # assert_equal 1, oo.cell('A',2)
725
+ # assert_equal 2, oo.cell('B',2)
726
+ # assert_equal 1, oo.cell('C',2)
727
+ # are stored as strings, not numbers
728
+
729
+ assert_equal 1, oo.cell('A',2).to_i
730
+ assert_equal 2, oo.cell('B',2).to_i
731
+ assert_equal 1, oo.cell('C',2).to_i
732
+
733
+ assert_equal 1, oo.cell('A',3)
734
+ assert_equal 3, oo.cell('B',3)
735
+ assert_equal 1, oo.cell('C',3)
736
+
737
+ assert_equal 'A', oo.cell('A',4)
738
+ assert_equal 'A', oo.cell('B',4)
739
+ assert_equal 'A', oo.cell('C',4)
725
740
 
726
- assert_equal 1, oo.cell('A',2).to_i
727
- assert_equal 2, oo.cell('B',2).to_i
728
- assert_equal 1, oo.cell('C',2).to_i
741
+ # assert_equal '0.01', oo.cell('A',5)
742
+ # assert_equal '0.01', oo.cell('B',5)
743
+ # assert_equal '0.01', oo.cell('C',5)
744
+ #
745
+ assert_equal 0.01, oo.cell('A',5)
746
+ assert_equal 0.01, oo.cell('B',5)
747
+ assert_equal 0.01, oo.cell('C',5)
748
+
749
+ assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
729
750
 
730
- assert_equal 1, oo.cell('A',3)
731
- assert_equal 3, oo.cell('B',3)
732
- assert_equal 1, oo.cell('C',3)
733
751
 
734
- assert_equal 'A', oo.cell('A',4)
735
- assert_equal 'A', oo.cell('B',4)
736
- assert_equal 'A', oo.cell('C',4)
752
+ # 1.0
737
753
 
738
- assert_equal '0.01', oo.cell('A',5)
739
- assert_equal '0.01', oo.cell('B',5)
740
- assert_equal '0.01', oo.cell('C',5)
754
+ # Cells values in row 1:
755
+ assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
756
+ assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
757
+ assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
758
+
759
+ # Cells values in row 2:
760
+ assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
761
+ assert_equal "2:string",oo.cell(2, 2)+":"+oo.celltype(2, 2).to_s
762
+ assert_equal "1:string",oo.cell(2, 3)+":"+oo.celltype(2, 3).to_s
763
+
764
+ # Cells values in row 3:
765
+ assert_equal "1.0:float",oo.cell(3, 1).to_s+":"+oo.celltype(3, 1).to_s
766
+ assert_equal "3.0:float",oo.cell(3, 2).to_s+":"+oo.celltype(3, 2).to_s
767
+ assert_equal "1.0:float",oo.cell(3, 3).to_s+":"+oo.celltype(3, 3).to_s
768
+
769
+ # Cells values in row 4:
770
+ assert_equal "A:string",oo.cell(4, 1)+":"+oo.celltype(4, 1).to_s
771
+ assert_equal "A:string",oo.cell(4, 2)+":"+oo.celltype(4, 2).to_s
772
+ assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
773
+
774
+ # Cells values in row 5:
775
+ assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
776
+ assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
777
+ assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
778
+
779
+ oo = Excel.new(File.join("test","simple_spreadsheet_from_italo.xls"))
780
+ oo.default_sheet = oo.sheets.first
781
+
782
+ assert_equal '1', oo.cell('A',1)
783
+ assert_equal '1', oo.cell('B',1)
784
+ assert_equal '1', oo.cell('C',1)
785
+
786
+ # assert_equal 1, oo.cell('A',2)
787
+ # assert_equal 2, oo.cell('B',2)
788
+ # assert_equal 1, oo.cell('C',2)
789
+ # are stored as strings, not numbers
790
+
791
+ assert_equal 1, oo.cell('A',2).to_i
792
+ assert_equal 2, oo.cell('B',2).to_i
793
+ assert_equal 1, oo.cell('C',2).to_i
794
+
795
+ assert_equal 1, oo.cell('A',3)
796
+ assert_equal 3, oo.cell('B',3)
797
+ assert_equal 1, oo.cell('C',3)
798
+
799
+ assert_equal 'A', oo.cell('A',4)
800
+ assert_equal 'A', oo.cell('B',4)
801
+ assert_equal 'A', oo.cell('C',4)
802
+
803
+ # assert_equal '0.01', oo.cell('A',5)
804
+ # assert_equal '0.01', oo.cell('B',5)
805
+ # assert_equal '0.01', oo.cell('C',5)
806
+ #
807
+ assert_equal 0.01, oo.cell('A',5)
808
+ assert_equal 0.01, oo.cell('B',5)
809
+ assert_equal 0.01, oo.cell('C',5)
810
+
811
+ assert_equal 0.03, oo.cell('a',5)+oo.cell('b',5)+oo.cell('c',5)
741
812
 
742
813
 
743
814
  # 1.0
@@ -746,7 +817,6 @@ class TestRoo < Test::Unit::TestCase
746
817
  assert_equal "1:string", oo.cell(1, 1)+":"+oo.celltype(1, 1).to_s
747
818
  assert_equal "1:string",oo.cell(1, 2)+":"+oo.celltype(1, 2).to_s
748
819
  assert_equal "1:string",oo.cell(1, 3)+":"+oo.celltype(1, 3).to_s
749
- end
750
820
 
751
821
  # Cells values in row 2:
752
822
  assert_equal "1:string",oo.cell(2, 1)+":"+oo.celltype(2, 1).to_s
@@ -764,9 +834,17 @@ class TestRoo < Test::Unit::TestCase
764
834
  assert_equal "A:string",oo.cell(4, 3)+":"+oo.celltype(4, 3).to_s
765
835
 
766
836
  # Cells values in row 5:
767
- assert_equal "0.01:percentage",oo.cell(5, 1)+":"+oo.celltype(5, 1).to_s
768
- assert_equal "0.01:percentage",oo.cell(5, 2)+":"+oo.celltype(5, 2).to_s
769
- assert_equal "0.01:percentage",oo.cell(5, 3)+":"+oo.celltype(5, 3).to_s
837
+ #assert_equal "0.01:percentage",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
838
+ #assert_equal "0.01:percentage",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
839
+ #assert_equal "0.01:percentage",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
840
+ # why do we get floats here? in the spreadsheet the cells were defined
841
+ # to be percentage
842
+ # TODO: should be fixed
843
+ # the excel gem does not support the cell type 'percentage' these
844
+ # cells are returned to be of the type float.
845
+ assert_equal "0.01:float",oo.cell(5, 1).to_s+":"+oo.celltype(5, 1).to_s
846
+ assert_equal "0.01:float",oo.cell(5, 2).to_s+":"+oo.celltype(5, 2).to_s
847
+ assert_equal "0.01:float",oo.cell(5, 3).to_s+":"+oo.celltype(5, 3).to_s
770
848
  end
771
849
 
772
850
  end
@@ -1171,10 +1249,10 @@ class TestRoo < Test::Unit::TestCase
1171
1249
  end
1172
1250
 
1173
1251
  def test_to_csv
1174
- after Date.new(2007,10,1) do
1252
+ after Date.new(2007,10,20) do
1175
1253
  if OPENOFFICE
1176
1254
  assert_nothing_raised(Timeout::Error) {
1177
- Timeout::timeout(10*60*2) do |timeout_length|
1255
+ Timeout::timeout(40*60*2) do |timeout_length|
1178
1256
  #puts Time.now.to_s + "test_to_csv Openoffice gestartet"
1179
1257
  oo = Openoffice.new(File.join("test","Bibelbund.ods"))
1180
1258
  oo.default_sheet = oo.sheets.first
@@ -1198,10 +1276,10 @@ class TestRoo < Test::Unit::TestCase
1198
1276
  end # OPENOFFICE
1199
1277
  end # after
1200
1278
 
1201
- after Date.new(2007,10,1) do
1279
+ after Date.new(2007,10,20) do
1202
1280
  if EXCEL
1203
1281
  assert_nothing_raised(Timeout::Error) {
1204
- Timeout::timeout(10*60*2) do |timeout_length|
1282
+ Timeout::timeout(40*60*2) do |timeout_length|
1205
1283
  #puts Time.now.to_s + "test_to_csv Excel gestartet"
1206
1284
  oo = Excel.new(File.join("test","Bibelbund.xls"))
1207
1285
  oo.default_sheet = oo.sheets.first
@@ -1223,4 +1301,76 @@ class TestRoo < Test::Unit::TestCase
1223
1301
  end
1224
1302
  end # def to_csv
1225
1303
 
1304
+ def test_bug_mehrere_datum
1305
+ if OPENOFFICE
1306
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
1307
+ oo.default_sheet = 'Sheet5'
1308
+ assert_equal :date, oo.celltype('A',4)
1309
+ assert_equal :date, oo.celltype('B',4)
1310
+ assert_equal :date, oo.celltype('C',4)
1311
+ assert_equal :date, oo.celltype('D',4)
1312
+ assert_equal :date, oo.celltype('E',4)
1313
+ assert_equal Date.new(2007,11,21), oo.cell('A',4)
1314
+ assert_equal Date.new(2007,11,21), oo.cell('B',4)
1315
+ assert_equal Date.new(2007,11,21), oo.cell('C',4)
1316
+ assert_equal Date.new(2007,11,21), oo.cell('D',4)
1317
+ assert_equal Date.new(2007,11,21), oo.cell('E',4)
1318
+ assert_equal :float, oo.celltype('A',5)
1319
+ assert_equal :float, oo.celltype('B',5)
1320
+ assert_equal :float, oo.celltype('C',5)
1321
+ assert_equal :float, oo.celltype('D',5)
1322
+ assert_equal :float, oo.celltype('E',5)
1323
+ assert_equal 42, oo.cell('A',5)
1324
+ assert_equal 42, oo.cell('B',5)
1325
+ assert_equal 42, oo.cell('C',5)
1326
+ assert_equal 42, oo.cell('D',5)
1327
+ assert_equal 42, oo.cell('E',5)
1328
+ assert_equal :string, oo.celltype('A',6)
1329
+ assert_equal :string, oo.celltype('B',6)
1330
+ assert_equal :string, oo.celltype('C',6)
1331
+ assert_equal :string, oo.celltype('D',6)
1332
+ assert_equal :string, oo.celltype('E',6)
1333
+ assert_equal "ABC", oo.cell('A',6)
1334
+ assert_equal "ABC", oo.cell('B',6)
1335
+ assert_equal "ABC", oo.cell('C',6)
1336
+ assert_equal "ABC", oo.cell('D',6)
1337
+ assert_equal "ABC", oo.cell('E',6)
1338
+ end # Openoffice
1339
+
1340
+ if EXCEL
1341
+ oo = Excel.new(File.join("test","numbers1.xls"))
1342
+ oo.default_sheet = 'Sheet5'
1343
+ assert_equal :date, oo.celltype('A',4)
1344
+ assert_equal :date, oo.celltype('B',4)
1345
+ assert_equal :date, oo.celltype('C',4)
1346
+ assert_equal :date, oo.celltype('D',4)
1347
+ assert_equal :date, oo.celltype('E',4)
1348
+ assert_equal Date.new(2007,11,21), oo.cell('A',4)
1349
+ assert_equal Date.new(2007,11,21), oo.cell('B',4)
1350
+ assert_equal Date.new(2007,11,21), oo.cell('C',4)
1351
+ assert_equal Date.new(2007,11,21), oo.cell('D',4)
1352
+ assert_equal Date.new(2007,11,21), oo.cell('E',4)
1353
+ assert_equal :float, oo.celltype('A',5)
1354
+ assert_equal :float, oo.celltype('B',5)
1355
+ assert_equal :float, oo.celltype('C',5)
1356
+ assert_equal :float, oo.celltype('D',5)
1357
+ assert_equal :float, oo.celltype('E',5)
1358
+ assert_equal 42, oo.cell('A',5)
1359
+ assert_equal 42, oo.cell('B',5)
1360
+ assert_equal 42, oo.cell('C',5)
1361
+ assert_equal 42, oo.cell('D',5)
1362
+ assert_equal 42, oo.cell('E',5)
1363
+ assert_equal :string, oo.celltype('A',6)
1364
+ assert_equal :string, oo.celltype('B',6)
1365
+ assert_equal :string, oo.celltype('C',6)
1366
+ assert_equal :string, oo.celltype('D',6)
1367
+ assert_equal :string, oo.celltype('E',6)
1368
+ assert_equal "ABC", oo.cell('A',6)
1369
+ assert_equal "ABC", oo.cell('B',6)
1370
+ assert_equal "ABC", oo.cell('C',6)
1371
+ assert_equal "ABC", oo.cell('D',6)
1372
+ assert_equal "ABC", oo.cell('E',6)
1373
+ end # Excel
1374
+ end
1375
+
1226
1376
  end # class
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.6.0</a>
36
+ <a href="http://rubyforge.org/projects/roo" class="numbers">0.6.1</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
@@ -225,7 +225,9 @@ oo.to_csv
225
225
  </code>
226
226
  </pre>
227
227
 
228
- to write to the standard output or
228
+ <p>to write to the standard output or</p>
229
+
230
+
229
231
  <pre>
230
232
  <code>
231
233
  oo.to_csv("somefile.txt")
@@ -248,9 +250,10 @@ Replace Openoffice with
248
250
  </code>
249
251
  </pre>
250
252
 
251
- <p>All methode are the same for OpenOffice and Excel-objects. The only difference
252
- 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>
253
-
253
+ All methode are the same for OpenOffice and Excel-objects.
254
+ <strike> The only difference
255
+ 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,..).
256
+ </strike>
254
257
 
255
258
  <p>Formulas can only be handled in OpenOffice-spreadsheets.</p>
256
259
 
@@ -274,11 +277,19 @@ is the setting of the default-worksheet. OpenOffice uses the name of the workshe
274
277
  <td>yes</td>
275
278
  <td>yes</td>
276
279
  </tr>
280
+ <tr>
281
+ <td>celltype</td>
282
+ <td>:percentage</td>
283
+ <td>:float</td>
284
+ </tr>
277
285
  </table>
278
286
 
279
287
 
280
288
 
281
289
 
290
+ <p>The parseexcel-gem does not support the celltype &#8216;percentage&#8217; but uses &#8216;float&#8217; instead. This is not a big deal as you can also use &#8216;float&#8217; to do calculate with these cells.</p>
291
+
292
+
282
293
  <p>Old .sxc OpenOffice files are currently not supported &#8211; please load these files and save it as an &#8220;OpenDocument Spreadsheet (.ods)&#8221;.</p>
283
294
 
284
295
 
@@ -412,7 +423,7 @@ Remote access with <span class="caps">SOAP</span> is nothing specific to roo, yo
412
423
  <li>Dirk Huth f&uuml;rs Testen unter Windows</li>
413
424
  </ul>
414
425
  <p class="coda">
415
- <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 3rd October 2007<br>
426
+ <a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 8th October 2007<br>
416
427
  Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
417
428
  </p>
418
429
  </div>
data/website/index.txt CHANGED
@@ -153,6 +153,7 @@ oo.to_csv
153
153
  </pre>
154
154
 
155
155
  to write to the standard output or
156
+
156
157
  <pre>
157
158
  <code>
158
159
  oo.to_csv("somefile.txt")
@@ -172,8 +173,10 @@ Replace Openoffice with
172
173
  </code>
173
174
  </pre>
174
175
 
175
- All methode are the same for OpenOffice and Excel-objects. The only difference
176
+ All methode are the same for OpenOffice and Excel-objects.
177
+ <strike> The only difference
176
178
  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,..).
179
+ </strike>
177
180
 
178
181
  Formulas can only be handled in OpenOffice-spreadsheets.
179
182
 
@@ -183,6 +186,9 @@ table(border:1px solid black).
183
186
  |feature|Open Office|Excel|
184
187
  |formulas|yes|no|
185
188
  |to_yaml|yes|yes|
189
+ |celltype|:percentage|:float|
190
+
191
+ 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 calculate with these cells.
186
192
 
187
193
  Old .sxc OpenOffice files are currently not supported - please load these files and save it as an "OpenDocument Spreadsheet (.ods)".
188
194
 
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.6.0
7
- date: 2007-10-06 00:00:00 +02:00
6
+ version: 0.6.1
7
+ date: 2007-10-11 00:00:00 +02:00
8
8
  summary: roo can access the contents of OpenOffice-Spreadsheets and Excel-Spreadsheets
9
9
  require_paths:
10
10
  - lib