Skip to content

Commit

Permalink
fix: resolve csv column off by one error
Browse files Browse the repository at this point in the history
  • Loading branch information
patsier-cms committed May 21, 2024
1 parent eca314c commit f20bae8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/versions/common/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function csvColumnName(column: number): string {
if (column < ASCII_UPPERCASE.length) return ASCII_UPPERCASE[column]

return (
ASCII_UPPERCASE[Math.floor(column / ASCII_UPPERCASE.length)] +
ASCII_UPPERCASE[Math.floor(column / ASCII_UPPERCASE.length) - 1] +
csvColumnName(column % ASCII_UPPERCASE.length)
)
}
Expand Down
7 changes: 7 additions & 0 deletions test/common/csv.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import test from "ava"
import { csvColumnName } from "../../src/versions/common/csv.js"

test("csvColumnName", (t) => {
t.is(csvColumnName(0), "A")
t.is(csvColumnName(26), "AA")
})

0 comments on commit f20bae8

Please sign in to comment.