Skip to content

Loading…

Fix Cell#r_abs to handle multi-digit row numbers and multi-letter column ids. #49

Merged
merged 2 commits into from

2 participants

@joekain
Collaborator

I took a shot at updating the specs this time, hope the extra row here is ok.

@randym
Owner

wow, @joekain back again with not only a great bug fix, but specs to prove it!
I'm going to give you permissions to the repo so you dont have to play the fork->pull game anymore.

@randym randym merged commit 547c5e6 into randym:master
@joekain
Collaborator

@randym Thanks!

@randym
Owner

Very strange thing in 1.8.7

You added:
@ws.add_row (0..26).map { |index| index }
to the spec, which looks fine and I would 100% expect it to work - but on 1.8.7 it complains that
(0..26).map { |index| index } is not an array.

Of course it is an array... anyway, I made a small change to the spec so that it stores the array in a variable before passing it to add row... only an issue on 1.8.7, dont know why and it probably is not worth it to try to find out as 1.9.2 + did not have a problem.

Do you know about http://travis-ci.org ?

When you clone master and push any changes it will run all specs for you and report to irc.freenode.net#axlsx
You might have a look. Aside from being owe of my favorite oos apps - it really makes a difference to have that kind of CI level testing running on every pus.

@joekain
Collaborator

That is weird. I hadn't see http://travis-ci.org before but it looks really cool. I'll definitely be using it.

Thanks.

@randym
Owner

travis-ci is -awesome-, and the community is great too.
I probably spend 80% of my non-day-job time working with those guys. join us on #travisci - we are going to changing the world of open source TDD/BDD. rails uses travis, ruby uses travis, eventually everyone will use travis. It's the Github of CI.

@randym
Owner

travis-ci is -awesome-, and the community is great too.
I probably spend 80% of my non-day-job time working with those guys. join us on #travisci - we are going to changing the world of open source TDD/BDD. rails uses travis, ruby uses travis, eventually everyone will use travis. It's the Github of CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 4 additions and 1 deletion.
  1. +1 −1 lib/axlsx/workbook/worksheet/cell.rb
  2. +3 −0 test/workbook/worksheet/tc_cell.rb
View
2 lib/axlsx/workbook/worksheet/cell.rb
@@ -230,7 +230,7 @@ def r
# @example Absolute Cell Reference
# ws.rows.first.cells.first.r #=> "$A$1"
def r_abs
- "$#{r.split('').join('$')}"
+ "$#{r.match(%r{([A-Z]+)([0-9]+)})[1,2].join('$')}"
end
# @return [Integer] The cellXfs item index applied to this cell.
View
3 test/workbook/worksheet/tc_cell.rb
@@ -9,6 +9,8 @@ def setup
p.workbook.styles.add_style :sz=>20
@row = @ws.add_row
@c = @row.add_cell 1, :type=>:float, :style=>1
+ @ws.add_row (0..26).map { |index| index }
+ @cAA = @ws["AA2"]
end
def test_initialize
@@ -42,6 +44,7 @@ def test_r
def test_r_abs
assert_equal(@c.r_abs,"$A$1", "calculate absolute cell reference")
+ assert_equal(@cAA.r_abs,"$AA$2", "needs to accept multi-digit columns")
end
def test_style
Something went wrong with that request. Please try again.