How to write a cell address encoder in ruby
medium.com
medium.com
EDIT:
Correct me if I'm wrong, but spreadsheet column addresses are basically just base-26 encoded numbers, where the digits are 'A'...'Z'. If you convert them into their base-2 representation, you could store 65536 rows, instead of the 26*26=676 you can store with two integers.
An additional consideration would be that spreadsheets are often of fixed width and grow downwards, so you can use more bits for indexing rows than columns. This depends on the use-case though.
I'm not sure on how actual spreadsheets encode cell addresses. In my particular case, what I had to do was to find a way to (efficiently) encode any cell address in the range [A1..ZZ(10^6)] into a 64 bits integer. I needed 64 bits integers because that's what I use as a key to store/retrieve cells for the in-memory data store. (An avltree indexed by integer keys.)
As I mentioned in the post, the real code was written in C and targeted 64 bits platforms. Maybe that's way I doesn't make sense under OOP lenses on 32 bits systems.
Maybe I'll do a follow up post on "how to store spreadsheets cells on avltrees" to show why this encoding mechanism may make sense...
Thanks for you comments. Let's see how it goes!