#!/usr/bin/env python3
import string
defgetcolumnname
(columnindex)
: ret =
'' ci = columnindex -
1 index = ci //
26if index >0:
ret += getcolumnname(index)
ret += string.ascii_uppercase[ci %26]
return ret
defmain()
: a =[1
,26,27
,52,53
,72,73
,1*26
**2+2
*26**1
+3,4
*26**3
+3*26
**2+2
*26**1
+1]# a z aa az ba bt bu abc dcba
for i in a:
print
(f"="
)if __name__ ==
'__main__'
: main(
)
執行結果如下:
1=a
26=z
27=aa
52=az
53=ba
72=bt
73=bu
731=abc
72385=dcba
但excel應該用不了這麼多列,所以用遞迴對效能的影響也是可控的。我在excel 2007上試的,**最大列數為16384(xfd)。
Python操作EXCEL列轉行
總結業務整理了工藝的模板需要匯入到系統中,但是系統中的表結構是工序只有乙個列,不同值按行分開,而模板是每道工序分成多個列,這個時候可以使用python自動處理execl,將列自動轉換成行。如下 示例 import pandas as pd 如下 示例 讀取資料 df pd.read excel 拆列...
使用poi匯出excel根據指定列自動合併行
一 效果圖 二 js function assemble dg columns arr.push arr.push arr.push arr.push arr.push arr.push arr.push arr.push arr.push arr.push arr.push arr.push re...
EXCEL 根據某幾列確定其他列數值
1.在excel中,根據三列數值確定某一列數值 現在有sheet1 a,b,c,d三列 而sheet2 a b,c,d abc分別一一對應,是一樣的內容,只不過a,b中對應sheet1的數值是混亂的,所以d得自動填充進去 解決方法,在d2中填入 lookup 0 sheet1 a 2 a 2300 ...