当前位置:网站首页>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
边栏推荐
- Erreur de hauteur du clavier souple
- 程序员养生宝典
- [getting started] extract non repeating integers
- PWN attack and defense world int_ overflow
- Access报表实现小计功能
- Li Kou daily question - Day 32 -1822 Symbol of array element product
- Download xshell and xftp
- Find the nearest n-th power of 2
- 2022.6.30 省赛+蓝桥国赛记录
- 【力扣10天SQL入门】Day10 控制流
猜你喜欢
Principle and process of embossing
Lm08 mesh series mesh inversion (fine)
window c盘满了
[staff] high and low octave mark (the notes in the high octave mark | mark range are increased by one octave as a whole | low octave mark | mark range are decreased by one octave as a whole)
The triode is a great invention
Erreur de hauteur du clavier souple
[getting started] input n integers and output the smallest K of them
Conscience Amway universal wheel SolidWorks model material website
Aardio - Shadow Gradient Text
[getting started] extract non repeating integers
随机推荐
[introduction] approximate value
Kickback -- find the first palindrome character in a group of characters
[getting started] extract non repeating integers
Cyclic neural network
Connect timed out of database connection
[MySQL learning notes 25] SQL statement optimization
[staff] key number (key number identification position | key number marking list | a major key identification principle | F, C, G position marking ascending | F major key identification principle | B
php laravel微信支付
How to get a SharePoint online site created using the office365 group template
Php laraver Wechat payment
Caesar
【批处理DOS-CMD命令-汇总和小结】-Cmd窗口中常用操作符(<、<<、&<、>、>>、&>、&、&&、||、|、()、;、@)
【mysql学习笔记25】sql语句优化
Insufficient executors to build thread pool
[untitled]
Find the nearest n-th power of 2
What information does the supplier need to know about Audi EDI project?
empirical study and case study
【mysql学习笔记28】存储函数
SharePoint - modify web application authentication using PowerShell