diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-03 22:02:43 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-11-03 22:02:43 +0000 |
commit | cf96e06b1f5e9d0037874f49c99e6f2b38369f5b (patch) | |
tree | c929f670b296e11b1c75a8508a68c5414b3f3153 | |
parent | c137d4ca681d8f68654a5273e760fa21af08b21b (diff) |
alphastream variable now fits Excel max cols
-rw-r--r-- | reader/reader.go | 7 | ||||
-rw-r--r-- | reader/reader_test.go | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/reader/reader.go b/reader/reader.go index b5d088b..c49bd5a 100644 --- a/reader/reader.go +++ b/reader/reader.go @@ -12,6 +12,9 @@ import ( "github.com/tealeg/xlsx" ) +const maxCols = 16384 +const maxAlphabets = (maxCols / 26) - 1 + //DatamapLine - a line from the datamap. type DatamapLine struct { Key string @@ -84,10 +87,10 @@ func alphaSingle() []string { return letters } -var alphaStream = alphas(10) +var alphaStream = alphas(maxAlphabets) //alphas generates the alpha column compont of Excel cell references -//Combines n alphabets to do this. +//Adds n alphabets to the first (A..Z) alphabet. func alphas(n int) []string { single := alphaSingle() slen := len(single) diff --git a/reader/reader_test.go b/reader/reader_test.go index 109b605..ff9a55c 100644 --- a/reader/reader_test.go +++ b/reader/reader_test.go @@ -1,6 +1,7 @@ package reader import ( + "log" "testing" ) @@ -46,6 +47,11 @@ func TestAlphaStream(t *testing.T) { if alphaStream[26] != "AA" { t.Errorf("Expected AA, got %v", alphaStream[26]) } + if len(alphaStream) > maxCols { + t.Errorf(`Number of columns in alphastream exceeds Excel maximum. + alphastream contains %d, maxCols is %d`, len(alphaStream), maxCols) + } + log.Printf("Length of alphastream: %d", len(alphaStream)) } func TestAlphaSingle(t *testing.T) { |