py excel 文本化

py excel 文本化


代码上
#  -*- coding: gbk -*-
#
    对应参考excel(obj)
#
        提供访问excel 参考 sql 访问接口
#
excelAction.py   "G:\Documents and Settings\ch\桌面\非四大总计.xls" "A,C,B" "|"
from  pyExcelerator  import   *
import  sys

txls 
=  parse_xls(sys.argv[ 1 ])
findcols
= sys.argv[ 2 ].split( ' , ' )
tsplit
= " %s " % (sys.argv[ 3 ])


bmug
= lambda  str : unicode(str).encode( " utf8 " )

def  cfsize(cha):
    
if  len(cha) == 1
        
return  ord(cha) - ord( ' A '
    
else  : 
        fsize
= 0
        fnum
= cfsize( ' Z ' ) + 1
        cc
= list(cha)
        
for  tnum  in  range(len(cc)):
            fsize
+= fnum * tnum + cfsize(cc[tnum])
        
return  fsize


for  tnum  in  range(len(txls)) :
    
try :
        sheetname
= txls[tnum][0]
        sheetdata
= txls[tnum][ 1 ]
        
for  tnum  in  range(max([tmp[0]  for  tmp  in  sheetdata])):
            
try  :
                stmp
= str(tnum + 1 ) + tsplit
                
for  tmp  in  findcols :
                    stmp
+= sheetdata[(tnum,cfsize(tmp))] + tsplit
                
print  stmp
            
except :
                
print  sys.exc_info()[0]
                
pass
    
except :
        
print  sys.exc_info()[0]
        
pass

print   ' close '  


整理 www.blogjava.net/Good-Game

你可能感兴趣的:(py excel 文本化)