Skip to content

Commit

Permalink
Fix warnings when running test/suite.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Dec 15, 2015
1 parent 1b171ab commit cbdb7bd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions lib/spreadsheet/excel/reader.rb
Expand Up @@ -909,6 +909,7 @@ def read_worksheet worksheet, offset
#p work
end
when :continue # this contains the actual note text
@noteObject ||= nil
if previous == :txo && @noteObject
#puts "\nDEBUG: found Continue record"
continueFmt = work.unpack('C')
Expand Down
12 changes: 6 additions & 6 deletions lib/spreadsheet/worksheet.rb
Expand Up @@ -342,17 +342,17 @@ def compact!

# detect first non-empty non-nil column if first column is empty or nil
if (@dimensions[0]..@dimensions[1]).inject(true){|t, j| t && row(j)[@dimensions[2]].nil?}
(@dimensions[2]..@dimensions[3]).each do |i|
break unless (@dimensions[0]..@dimensions[1]).inject(true){|t, j| t && (row(j)[i].nil? || row(j)[i].empty?)}
@dimensions[2] = i
(@dimensions[2]..@dimensions[3]).each do |idx|
break unless (@dimensions[0]..@dimensions[1]).inject(true){|t, j| t && (row(j)[idx].nil? || row(j)[idx].empty?)}
@dimensions[2] = idx
end
end

# detect last non-empty non-nil column if last column is empty or nil
if (@dimensions[0]..@dimensions[1]).inject(true){|t, j| t && row(j)[@dimensions[3]].nil?}
(@dimensions[2]..@dimensions[3]).reverse_each do |i|
break unless (@dimensions[0]..@dimensions[1]).inject(true){|t, j| t && (row(j)[i].nil? || row(j)[i].empty?)}
@dimensions[3] = i
(@dimensions[2]..@dimensions[3]).reverse_each do |idx|
break unless (@dimensions[0]..@dimensions[1]).inject(true){|t, j| t && (row(j)[idx].nil? || row(j)[idx].empty?)}
@dimensions[3] = idx
end
@dimensions[3] = @dimensions[3]
end
Expand Down
8 changes: 3 additions & 5 deletions test/integration.rb
Expand Up @@ -70,7 +70,7 @@ def test_empty_workbook
def test_missing_format
path = File.join @data, 'test_missing_format.xls'
assert_nothing_thrown do
workbook = Spreadsheet.open(path, "rb")
Spreadsheet.open(path, "rb")
end
end
def test_version_excel97__excel2010__utf16
Expand Down Expand Up @@ -1391,10 +1391,8 @@ def test_write_worksheet_visibility
path = File.join @var, 'test_write_worksheet_visibility.xls'
sheet1 = book.create_worksheet
sheet1.visibility = :hidden
sheet2 = book.create_worksheet
assert_nothing_raised do
book.write path
end
book.create_worksheet
book.write path
book2 = Spreadsheet.open path
assert_instance_of Excel::Workbook, book2
assert_equal(:hidden, book2.worksheet(0).visibility)
Expand Down

0 comments on commit cbdb7bd

Please sign in to comment.