diff options
| author | Randy Morgan <[email protected]> | 2012-04-01 17:00:06 -0700 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-01 17:00:06 -0700 |
| commit | bcc7c8c4e85a6ed53f134d633e8f81fd313d6c8d (patch) | |
| tree | 9a474295ec099e303b3711338962d84cb7a43596 /lib | |
| parent | 225edfc837e99167072fdf15e4ee3a5af9cfe96c (diff) | |
| parent | 44c77ed27b20c4ebe1c9c8faf6ad80701d7f567e (diff) | |
| download | caxlsx-bcc7c8c4e85a6ed53f134d633e8f81fd313d6c8d.tar.gz caxlsx-bcc7c8c4e85a6ed53f134d633e8f81fd313d6c8d.zip | |
Merge pull request #74 from joekain/wide
Wide
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb index dd628562..46d1c9bf 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -57,7 +57,7 @@ module Axlsx def self.name_to_indices(name) raise ArgumentError, 'invalid cell name' unless name.size > 1 v = name[/[A-Z]+/].reverse.chars.reduce({:base=>1, :i=>0}) do |val, c| - val[:i] += ((c.bytes.first - 65) + val[:base]); val[:base] *= 26; val + val[:i] += ((c.bytes.first - 64) * val[:base]); val[:base] *= 26; val end [v[:i]-1, ((name[/[1-9][0-9]*/]).to_i)-1] @@ -71,9 +71,9 @@ module Axlsx chars = [] while index >= 26 do chars << ((index % 26) + 65).chr - index /= 26 + index = index / 26 - 1 end - chars << ((chars.empty? ? index : index-1) + 65).chr + chars << (index + 65).chr chars.reverse.join end |
