当前位置:网站首页>数字转excel的字符串坐标
数字转excel的字符串坐标
2022-07-01 07:57:00 【dorlolo】
//获取excel坐标
func GetEcelAxis(row int, columnCount int) string {
var column = getColumnIndex(columnCount)
return fmt.Sprintf("%s%d", column, row)
}
//获取excel的列索引
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
}
这里面主要是列转换成英文字母的索引
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
}
输出
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
边栏推荐
猜你喜欢

Significance and measures of source code encryption

【批处理DOS-CMD命令-汇总和小结】-Cmd窗口中常用操作符(<、<<、&<、>、>>、&>、&、&&、||、|、()、;、@)

web254

2022 test questions and mock examinations for main principals of hazardous chemicals business units

Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)

2022 test question bank and simulation test of tea master (primary) operation certificate

base64

【入门】提取不重复的整数

SharePoint - how to quickly check whether SharePoint is standard or enterprise edition?

Office365 - how to use stream app to watch offline files at any time
随机推荐
图扑软件通过 CMMI5 级认证!| 国际软件领域高权威高等级认证
2022 Guangdong Provincial Safety Officer a certificate third batch (main person in charge) special operation certificate examination question bank simulated examination platform operation
postgresql源码学习(26)—— Windows vscode远程调试Linux上的postgresql
Cmake I two ways to compile source files
Latex table
力扣每日一题-第31天-202.快乐数
LM08丨网格系列之网格反转(精)
凸印的印刷原理及工艺介绍
SharePoint - modify web application authentication using PowerShell
Sqlalchemy creating MySQL_ Table
[software] phantomjs screenshot
038 network security JS
如何使用layui将数据库中的数据以表格的形式展现出来
Insufficient executors to build thread pool
matlab保存DB4i深度相机图片
Caesar
Rk3399 platform development series explanation (network debugging) 7.30. What will affect the sending process of TCP packets?
Office365 - how to use stream app to watch offline files at any time
[website architecture] solve 90% of distributed transactions in one move, and introduce the working principles and application scenarios of database transactions and distributed transactions
Basic knowledge of MATLAB