roo 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ == 0.2.5 2007-06-17
2
+
3
+ * 2 enhancements:
4
+ * Excel: row method implemented
5
+ * more tests
6
+ * 1 bugfix:
7
+ * Openoffice: row method fixed
8
+
1
9
  == 0.2.4 2007-06-16
2
10
  * 1 bugfix:
3
11
  * ID 11605 Two cols with same value: crash roo (openoffice version only)
data/lib/roo/excel.rb CHANGED
@@ -16,7 +16,7 @@ class Excel < Openoffice
16
16
  else
17
17
  #worksheet = @workbook.worksheet(0)
18
18
  # p @workbook
19
- p @workbook.worksheet(0)
19
+ # p @workbook.worksheet(0)
20
20
  ["aaa","bbb","ccc"]
21
21
  end
22
22
  end
@@ -80,8 +80,20 @@ class Excel < Openoffice
80
80
 
81
81
  def row(rownumber)
82
82
  worksheet = @workbook.worksheet(@default_sheet)
83
- row = worksheet.row(rownumber)
84
- row
83
+ therow = worksheet.row(rownumber-1)
84
+ result = []
85
+ therow.each {|cell|
86
+ case cell.type
87
+ when :numeric then result << cell.to_i
88
+ when :text then result << cell.to_s('latin1')
89
+ when :date then result << cell.date
90
+ else
91
+ return result << cell.to_s
92
+ end
93
+
94
+ #result << cell.value
95
+ }
96
+ return result
85
97
  end
86
98
 
87
99
  def first_column
@@ -126,14 +126,20 @@ class Openoffice
126
126
  def row(rownumber)
127
127
  read_cells unless @cells_read
128
128
  result = []
129
+ tmp_arr = []
129
130
  @cell.each_pair {|key,value|
131
+
130
132
  y,x = key.split(',')
131
133
  x = x.to_i
132
134
  y = y.to_i
133
135
  if y == rownumber
134
- result[x-1,rownumber] = value
136
+ tmp_arr[x] = value
135
137
  end
136
138
  }
139
+ result = tmp_arr[1..-1]
140
+ while result[-1] == nil
141
+ result = result[0..-2]
142
+ end
137
143
  result
138
144
  end
139
145
 
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 = 2
5
- TINY = 4
5
+ TINY = 5
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
@@ -2,11 +2,11 @@ require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
3
  class TestRoo < Test::Unit::TestCase
4
4
 
5
- OPENOFFICE = true # toggle Openoffice-Spreadsheet Test on/off
6
- EXCEL = true # do Excel Tests?
7
- GOOGLE = false # toggle Google-Spreadsheet Test on/off
5
+ OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
6
+ EXCEL = true # do Excel Tests?
7
+ GOOGLE = false # do Google-Spreadsheet Tests?
8
8
 
9
- OPENOFFICEWRITE = false # Tests fuer schreibenden Zugriff auf OO-Dokumente
9
+ OPENOFFICEWRITE = false # experimental: write access with OO-Dokuments
10
10
 
11
11
  def setup
12
12
  if GOOGLE
@@ -244,18 +244,32 @@ end
244
244
  assert_equal 44, oo.cell('d',12)
245
245
  assert_equal 45, oo.cell('e',12)
246
246
  assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
247
+ assert_equal "einundvierzig", oo.cell('a',16)
248
+ assert_equal "zweiundvierzig", oo.cell('b',16)
249
+ assert_equal "dreiundvierzig", oo.cell('c',16)
250
+ assert_equal "vierundvierzig", oo.cell('d',16)
251
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
252
+ assert_equal ["einundvierzig", "zweiundvierzig", "dreiundvierzig", "vierundvierzig", "fuenfundvierzig"], oo.row(16)
247
253
  if EXCEL
248
- if DateTime.now > Date.new(2007,6,17)
249
- #-- Excel
250
- oo = Excel.new(File.join("test","numbers1.xls"))
251
- oo.default_sheet = 1 # oo.sheets.first
252
- assert_equal 41, oo.cell('a',12)
253
- assert_equal 42, oo.cell('b',12)
254
- assert_equal 43, oo.cell('c',12)
255
- assert_equal 44, oo.cell('d',12)
256
- assert_equal 45, oo.cell('e',12)
257
- assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
258
- end
254
+ #-- Excel
255
+ oo = Excel.new(File.join("test","numbers1.xls"))
256
+ oo.default_sheet = 1 # oo.sheets.first
257
+ assert_equal 41, oo.cell('a',12)
258
+ assert_equal 42, oo.cell('b',12)
259
+ assert_equal 43, oo.cell('c',12)
260
+ assert_equal 44, oo.cell('d',12)
261
+ assert_equal 45, oo.cell('e',12)
262
+ assert_equal [41,42,43,44,45], oo.row(12)
263
+ assert_equal "einundvierzig", oo.cell('a',16)
264
+ assert_equal "zweiundvierzig", oo.cell('b',16)
265
+ assert_equal "dreiundvierzig", oo.cell('c',16)
266
+ assert_equal "vierundvierzig", oo.cell('d',16)
267
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
268
+ assert_equal ["einundvierzig",
269
+ "zweiundvierzig",
270
+ "dreiundvierzig",
271
+ "vierundvierzig",
272
+ "fuenfundvierzig"], oo.row(16)
259
273
  end
260
274
  if DateTime.now > Date.new(2007,6,17)
261
275
  #-- GOOGLE
@@ -268,6 +282,17 @@ end
268
282
  assert_equal 44, oo.cell('d',12)
269
283
  assert_equal 45, oo.cell('e',12)
270
284
  assert_equal [41.0,42.0,43.0,44.0,45.0], oo.row(12)
285
+ assert_equal "einundvierzig", oo.cell('a',16)
286
+ assert_equal "zweiundvierzig", oo.cell('b',16)
287
+ assert_equal "dreiundvierzig", oo.cell('c',16)
288
+ assert_equal "vierundvierzig", oo.cell('d',16)
289
+ assert_equal "fuenfundvierzig", oo.cell('e',16)
290
+ assert_equal "xxxfuenfundvierzig", oo.cell('e',16)
291
+ assert_equal ["einundvierzig",
292
+ "zweiundvierzig",
293
+ "dreiundvierzig",
294
+ "vierundvierzig",
295
+ "fuenfundvierzig"], oo.row(16)
271
296
  end
272
297
  end
273
298
  end
@@ -524,15 +549,51 @@ end
524
549
 
525
550
  def test_bug_contiguous_cells
526
551
  if OPENOFFICE
527
- oo = Openoffice.new(File.join("test","numbers1.ods"))
528
- oo.default_sheet = "Sheet4"
529
- assert_equal Date.new(2007,06,16), oo.cell('a',1)
530
- assert_equal 10, oo.cell('b',1)
531
- assert_equal 10, oo.cell('c',1)
532
- assert_equal 10, oo.cell('d',1)
533
- assert_equal 10, oo.cell('e',1)
552
+ oo = Openoffice.new(File.join("test","numbers1.ods"))
553
+ oo.default_sheet = "Sheet4"
554
+ assert_equal Date.new(2007,06,16), oo.cell('a',1)
555
+ assert_equal 10, oo.cell('b',1)
556
+ assert_equal 10, oo.cell('c',1)
557
+ assert_equal 10, oo.cell('d',1)
558
+ assert_equal 10, oo.cell('e',1)
559
+ end
560
+ if EXCEL
561
+ oo = Excel.new(File.join("test","numbers1.xls"))
562
+ oo.default_sheet = 4
563
+ assert_equal Date.new(2007,06,16), oo.cell('a',1)
564
+ assert_equal 10, oo.cell('b',1)
565
+ assert_equal 10, oo.cell('c',1)
566
+ assert_equal 10, oo.cell('d',1)
567
+ assert_equal 10, oo.cell('e',1)
568
+ end
569
+ if GOOGLE
570
+ @goo.default_sheet = "Sheet4"
571
+ assert_equal Date.new(2007,06,16), @goo.cell('a',1)
572
+ assert_equal 10, @goo.cell('b',1)
573
+ assert_equal 10, @goo.cell('c',1)
574
+ assert_equal 10, @goo.cell('d',1)
575
+ assert_equal 10, @goo.cell('e',1)
534
576
  end
577
+ end
535
578
 
579
+ def DONT_test_large_file
580
+ if OPENOFFICE
581
+ count = 0
582
+ oo = Openoffice.new(File.join("test","Bibelbund.ods"))
583
+ oo.default_sheet = oo.sheets.first
584
+ oo.first_row.upto(oo.last_row) do |row|
585
+ oo.first_column.upto(oo.last_column) do |col|
586
+ unless oo.empty?(row,col)
587
+ count += 1
588
+ a = oo.cell(row,col)
589
+ # puts a
590
+ # b = gets
591
+ end
592
+ end
593
+ end
594
+ puts count.to_s+" cells with content"
536
595
  end
537
596
 
538
- end # class
597
+ end
598
+
599
+ 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.2.4</a>
36
+ <a href="http://rubyforge.org/projects/roo" class="numbers">0.2.5</a>
37
37
  </div>
38
38
  <h2>What</h2>
39
39
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: roo
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.4
6
+ version: 0.2.5
7
7
  date: 2007-06-17 00:00:00 +02:00
8
8
  summary: roo can access the contents of OpenOffice-Spreadsheets
9
9
  require_paths: