Skip to content

Instantly share code, notes, and snippets.

@pandanote-info
Created October 19, 2019 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pandanote-info/3fce90441b420fa4a6c40d47889d7bbc to your computer and use it in GitHub Desktop.
Save pandanote-info/3fce90441b420fa4a6c40d47889d7bbc to your computer and use it in GitHub Desktop.
A1形式の文字列をApache POIのgetRow及びgetCellメソッドの引数に指定できる数値の組(Tuple)に変換するためのScalaのメソッド。
// See https://pandanote.info/?p=5424 for details.
def toRowCell(c: String, r: Int): (Int,Int) = {
var ci: Int = 0
var power: Int = 1
c.toCharArray.reverse.foreach(cr => {
ci += (cr-'A'+1)*power
power *= 26
})
(r-1,ci-1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment