excel - 获取excel列标题的算法说明

标签 excel algorithm

根据这个主题: How to convert a column number (e.g. 127) into an excel column (e.g. AA)

我不明白算法中的内容: here

谁能给我解释一下,while 循环中发生了什么?

最佳答案

实际上,它是将列号“转换”为基数 26,其中“数字”是字母 A..Z。

例如,对于第 720 列:

  • 模数 = (720-1)%26 = 17
  • columnName = 'R'
  • 股息 = (720-17)/26 = 27
  • 模数 = (27-1)%26 = 0
  • columnName = A+columnName = AR
  • 股息 = (27-0)/26 = 1
  • 模数 = (1-1)%26 = 0
  • columnName = A + columnName = AAR
  • 股息 = (1-0)/26 = 0

导致 AAR

关于excel - 获取excel列标题的算法说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39515485/

相关文章:

Android打开文件并让用户选择哪个程序可以打开它

VBA Excel : FTP GetFile via WinINet

algorithm - 消除图中删除顶点的循环

ruby - 如何按定义的顺序对数组进行划分和排序

java - 自定义分区问题

excel - 使用python对excel中的行进行分组

VBA 群发邮件问题

algorithm - 是否有将多边形图像转换为方形图像的算法?

vba - 如何在 VBA + Excel 中使用多个条件的 INDEX 和 MATCH?

c++ - 遍历任意大小的子集