spreadsheet 0.6.7 → 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.6.8 / 20.01.2012
2
+
3
+ * adds the fix to allow the writing of empty rows, by ClemensP.
4
+ * Test also by ClemensP.
5
+
1
6
  === 0.6.7 / 18.01.2012
2
7
 
3
8
  * http://dev.ywesee.com/wiki.php/Gem/Spreadsheet points point 2.
data/lib/spreadsheet.rb CHANGED
@@ -42,7 +42,7 @@ module Spreadsheet
42
42
 
43
43
  ##
44
44
  # The version of Spreadsheet you are using.
45
- VERSION = '0.6.7'
45
+ VERSION = '0.6.8'
46
46
 
47
47
  ##
48
48
  # Default client Encoding. Change this value if your application uses a
@@ -756,14 +756,18 @@ and minimal code that generates this warning. Thanks!
756
756
  else
757
757
  height * TWIPS
758
758
  end
759
- # TODO: Row spacing
760
- data = [
759
+
760
+ attrs = [
761
761
  row.idx,
762
762
  row.first_used,
763
763
  row.first_unused,
764
764
  height,
765
- opts,
766
- ].pack binfmt(:row)
765
+ opts]
766
+
767
+ return if attrs.any?(&:nil?)
768
+
769
+ # TODO: Row spacing
770
+ data = attrs.pack binfmt(:row)
767
771
  write_op opcode(:row), data
768
772
  end
769
773
  def write_rowblock block
@@ -7,34 +7,49 @@ require 'spreadsheet/excel/writer/worksheet'
7
7
  module Spreadsheet
8
8
  module Excel
9
9
  module Writer
10
- class TestWorksheet < Test::Unit::TestCase
11
- def test_need_number
12
- sheet = Worksheet.new nil, nil
13
- assert_equal false, sheet.need_number?(10)
14
- assert_equal false, sheet.need_number?(114.55)
15
- assert_equal false, sheet.need_number?(0.1)
16
- assert_equal false, sheet.need_number?(0.01)
17
- assert_equal false, sheet.need_number?(0 / 0.0) # NaN
18
- assert_equal true, sheet.need_number?(0.001)
19
- assert_equal true, sheet.need_number?(10000000.0)
20
- end
21
- def test_write_merged_cells
22
- # top/bottom/left/right cell of test range 1/2
23
- r1t, r1b, r1l, r1r = 0, 0, 0, 1
24
- r2t, r2b, r2l, r2r = 1, 2, 0, 0
25
- book = Spreadsheet::Workbook.new
26
- sheet = book.create_worksheet
27
- sheet.merge_cells(r1t, r1l, r1b, r1r)
28
- sheet.merge_cells(r2t, r2l, r2b, r2r)
29
- assert_equal [[r1t, r1b, r1l, r1r], [r2t, r2b, r2l, r2r]], sheet.merged_cells
30
- io = StringIO.new
31
- book.write(io)
32
- book2 = Spreadsheet.open(io)
33
- sheet2 = book2.worksheet(0)
34
- sheet2[0,0] # trigger read_worksheet
35
- assert_equal [[r1t, r1b, r1l, r1r], [r2t, r2b, r2l, r2r]], sheet2.merged_cells
36
- end
37
- end
10
+ class TestWorksheet < Test::Unit::TestCase
11
+ def test_need_number
12
+ sheet = Worksheet.new nil, nil
13
+ assert_equal false, sheet.need_number?(10)
14
+ assert_equal false, sheet.need_number?(114.55)
15
+ assert_equal false, sheet.need_number?(0.1)
16
+ assert_equal false, sheet.need_number?(0.01)
17
+ assert_equal false, sheet.need_number?(0 / 0.0) # NaN
18
+ assert_equal true, sheet.need_number?(0.001)
19
+ assert_equal true, sheet.need_number?(10000000.0)
20
+ end
21
+
22
+ class RowMock
23
+ attr_accessor :idx, :first_used, :first_unused, :height, :outline_level
24
+
25
+ def initialize
26
+ @idx, @first_used, @first_unused, @height, @outline_level = 0,0,0,0,1
27
+ end
28
+
29
+ def method_missing name, *args
30
+ nil
31
+ end
32
+ end
33
+
34
+ def test_write_row_should_not_write_if_the_row_has_no_used_columns
35
+ sheet = Worksheet.new nil, nil
36
+ row = RowMock.new
37
+ row.first_used = nil
38
+
39
+ sheet.write_row row
40
+
41
+ assert_equal '', sheet.data
42
+ end
43
+
44
+ def test_write_row_should_write_if_any_column_is_used
45
+ sheet = Worksheet.new nil, nil
46
+ row = RowMock.new
47
+
48
+ sheet.write_row row
49
+
50
+ assert_equal false, sheet.data.empty?
51
+ end
52
+ end
38
53
  end
39
54
  end
40
55
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spreadsheet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 7
10
- version: 0.6.7
9
+ - 8
10
+ version: 0.6.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Masaomi Hatakeyama, Zeno R.R. Davatz
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-18 00:00:00 Z
18
+ date: 2012-01-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: ruby-ole