当前位置:网站首页>String coordinates of number to excel
String coordinates of number to excel
2022-07-01 08:05:00 【dorlolo】
// obtain excel coordinate
func GetEcelAxis(row int, columnCount int) string {
var column = getColumnIndex(columnCount)
return fmt.Sprintf("%s%d", column, row)
}
// obtain excel The column index
var columnIndexList = []string{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
func getColumnIndex(num int) string {
num--
var column = columnIndexList[num%26]
for num = num / 26; num > 0; num = num/26 - 1 {
column = columnIndexList[(num-1)%26] + column
}
return column
}
This is mainly an index that converts columns into English letters
func TestGetCellIndex(t *testing.T) {
t.Log(getColumnIndex(26)) //Z
t.Log(getColumnIndex(27)) //AA
t.Log(getColumnIndex(676)) //YZ
t.Log(getColumnIndex(702)) //ZZ
t.Log(getColumnIndex(1352)) //AYZ
}
Output
rc_test.go:14: Z
rc_test.go:15: AA
rc_test.go:16: YZ
rc_test.go:17: ZZ
rc_test.go:18: AYZ
边栏推荐
- [batch dos-cmd command - summary and summary] - Common operators in the CMD window (<, < <, & <,>, > >, & >, & >, & &, ||, (),;, @)
- Cmake I two ways to compile source files
- [untitled]
- php laravel微信支付
- uni 热更新
- Set up file server Minio for quick use
- Oracle create auto increment ID
- 038 network security JS
- PHP laravel wechat payment
- Basic knowledge of MATLAB
猜你喜欢

2022 mobile crane driver test exercises and online simulation test

Aardio - 阴影渐变文字
![[untitled]](/img/c2/63286ba00321c9cdef43ff40635a67.png)
[untitled]

web254

How to make the two financial transactions faster

Software testing methods and techniques - overview of basic knowledge

She is the "HR of others" | ones character

How to check ad user information?

Latex formula code

Gru of RNN
随机推荐
SharePoint - modify web application authentication using PowerShell
Thesis learning -- Analysis and Research on similarity query of hydrological time series
Gru of RNN
Insufficient executors to build thread pool
如何使用layui将数据库中的数据以表格的形式展现出来
LM08丨网格系列之网格反转(精)
Two expressions of string
Discussion on several research hotspots of cvpr2022
Five combination boxing, solving six difficult problems on campus and escorting the construction of educational informatization
Basic number theory -- combinatorial number
力扣每日一题-第31天-1790.仅执行一次字符串交换能否使两个字符串相等
How outlook puts together messages with the same discussion
源代码加密的意义和措施
[getting started] enter the integer array and sorting ID, and sort its elements in ascending or descending order
php laravel微信支付
Sorting out tcp/udp communication problems
Conscience Amway universal wheel SolidWorks model material website
The triode is a great invention
uni 热更新
【Redis】一气呵成,带你了解Redis安装与连接