当前位置:网站首页>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
边栏推荐
- LM08丨网格系列之网格反转(精)
- web254
- 【网站架构】一招搞定90%的分布式事务,实打实介绍数据库事务、分布式事务的工作原理应用场景
- 力扣——求一组字符中的第一个回文字符
- The triode is a great invention
- 【入门】输入整型数组和排序标识,对其元素按照升序或降序进行排序
- window c盘满了
- SQL number injection and character injection
- 2022 test question bank and simulation test of tea master (primary) operation certificate
- IMDB practice of emotion classification (simplernn, LSTM, Gru)
猜你喜欢

Lm08 mesh series mesh inversion (fine)

Set up file server Minio for quick use

Eigen matrix operation Library

Gui Gui programming (XV) - use scale to control font size changes

【入门】截取字符串

Download xshell and xftp

LM08丨网格系列之网格反转(精)

谈谈数字化转型的几个关键问题
![[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions](/img/2c/07d729d49b1d74553decac4588074e.png)
[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions

web254
随机推荐
【mysql学习笔记25】sql语句优化
数字转excel的字符串坐标
2022 electrician (intermediate) recurrent training question bank and answers
How to make the two financial transactions faster
[getting started] extract non repeating integers
SharePoint - how to quickly check whether SharePoint is standard or enterprise edition?
【批处理DOS-CMD-汇总】扩展变量-延迟变量cmd /v:on、cmd /v:off、setlocal enabledelayedexpansion、DisableDelayedExpansion
She is the "HR of others" | ones character
How do the top ten securities firms open accounts? In addition, is it safe to open a mobile account?
漏刻有时API接口实战开发系列(14):身份证实名鉴权验证
[batch DOS CMD summary] extension variables - delay variables CMD /v:on, CMD /v:off, SETLOCAL enabledelayedexpansion, disabledelayedexpansion
Software testing methods and techniques - overview of basic knowledge
Discussion on several research hotspots of cvpr2022
The triode is a great invention
SQL number injection and character injection
Rk3399 platform development series explanation (network debugging) 7.30. What will affect the sending process of TCP packets?
Microsoft stream - how to modify video subtitles
Instead of houses, another kind of capital in China is rising
EDA open source simulation tool verilator beginner 6: debugging examples
STM32 uses esp01s to go to the cloud, mqtt FX debugging