Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

python²Ù×÷excelÐÔÄÜÎÊÌâÇóÖú

http://bbs.chinaunix.net/thread-1586782-1-1.html
ÎÒ¸Õ¸ÕÓÃpythonдÁËÒ»¶Î²Ù×÷excelµÄ½Å±¾£¬Ä¿µÄÊǰÑÒ»¸öexcelÎļþ°´ÕÕijһÁÐÖеÄ×ֶβð·Ö³É¶à¸öÎļþ£¬ÀýÈç°´ÕÕ³ÇÊлòÕßÊ¡·ÝµÈ£¬µ«ÊÇ·¢ÏÖ´¦ÀíÒ»¸ö1700ÐеÄÎļþ²ð·Ö³É40¶à¸öÎļþʱҪÔËÐÐ30·ÖÖÓ×óÓÒ£¬ÐÔÄÜÌ«Âý£¬Çë¸ßÊÖ°ïæ¿´¿´Ôõô²ÅÄÜÓÅ»¯ÐÔÄÜ£¬Ð»Ð»¡£
ÐÂÊÖдµÄ½Å±¾£¬Çë²»Òª¼ûЦ£¬ÈçÏ£º
'''
Created on 2009-9-25
@author: vidon
'''
#_*_ coding:UTF-8 _*_
import os, sys, time
import win32com.client
xls=win32com.client.Dispatch("Excel.Application")
xls.Visible=False
source_path = input('ÇëÊäÈëÒª²Ù×÷µÄÎļþÃû·¾¶ÓëÃû³Æ£¨ÀýÈ磺D:\ABC\BOOK.XLS£©£º').replace('\r','')
target_path = input('ÇëÊäÈë´æ·ÅÊý¾Ý´¦Àí½á¹ûµÄĿ¼£¨ÀýÈ磺D:\BACK\)£º').replace('\r','')
x=int(input("ÇëÊäÈë±íÍ·µÄÐÐÊý£º").replace('\r',''))
y=int(input("ÇëÊäÈë×÷Ϊ²ð·ÖÊý¾ÝµÄÒÀ¾ÝËùÔÚÁеĺÅÂ룺").replace('\r',''))
if not os.path.exists(target_path):
    os.mkdir(target_path)
    print("ÒѾ­´´½¨Ö¸¶¨µÄĿ¼£¬×¼±¸´´½¨Îļþ£¬ÇëÉԵȷ·····")
else:
    print("×¼±¸´´½¨Îļþ£¬ÇëÉԵȷ·····")
   
#¶ÁȡԭʼÎļþ
book=xls.Workbooks.Open(source_path)
sheet=book.ActiveSheet
length = sheet.UsedRange.Rows.Count
y_length = sheet.UsedRange.Columns.Count
keyArray = []
for i in range((x+1),length):
    keyArray.append(sheet.Cells(i,y).Value)
  
#¸ù¾ÝÖ¸¶¨µÄÁÐÖеÄ×ֶδ´½¨ÐÂÎļþ
ll = len(keyArray)
for j in range(1,ll):
   
    filename = target_path + str(keyArray[j]) + ".xls"
    if os.path.exists (filename):
        continue
    else :
        sheet.Range(sheet.Cells(1,1),sheet.Cells(x,y_length)).select
        sheet.Range(sheet.Cells(1,1),sheet.Cells(x,y_length)).copy
        newbook = xls.Workbooks.Add()
&nb


Ïà¹ØÎĵµ£º

pythonѧϰ1 ʹÓÃÀà

#ʹÓÃÀà
class CPerson:
#Àà±äÁ¿ºÃ±ÈC++Öеľ²Ì¬³ÉÔ±±äÁ¿
population = 0

def SayHi(self):
print('Hello World')
def HowMany(self):
if CPerson.population == 1:
print('I am the only person here.')
else:
print(('We have %d perso ......

ÔÚWindowsÀï´î½¨PythonµÄGTK+»·¾³´î½¨×¢ÒâÊÂÏî

ÔÚWindowsÀï´î½¨PythonµÄGTK+»·¾³»¹ÊDZȽÏÂé·³µÄÓÐÒÔϼ¸¸ö×¢ÒâÊÂÏî
1¡¢PyGTKÍøÕ¾ÉÏϵİü£¬¿ÉÄÜûÓÐGladeÀࣨLib\site-packages\gtk-2.0\gtkĿ¼ÏÂûÓÐglade.pyd£©£¬Èç¹ûûÓÐÕâ¸öÀàÄã¾ÍÎÞ·¨ÔÚ³ÌÐòÀïµ¼ÈëGlade¹¤¾ß´´½¨µÄxml£¬ÊÖд½çÃæ»¹ÊÇͦÂé·³µÄ¡£
2¡¢GTKÍøÕ¾ÉϵÄGTK°ü£¬Ã»ÓаüÀ¨GladeµÄDLLÎļþ£¬»¹ÊÇÎÞ·¨¶ÁÈëGladeµÄxm ......

Pythonѧϰ±Ê¼Ç ¸ß¼¶Ö÷Ìâ

1.ÁбíµÄµÝ¹é---ÓÃÓÚÊä³öÁбí×Ö·û´®ÖеÄÿ¸öÔªËØ >>> def printList(L):
    #Èç¹ûΪ¿Õ£¬Ôòʲô¶¼²»×ö
    if not L:
        return
    #Èç¹ûÊÇÁ´±í£¬Ôò¶ÔµÚÒ»¸öÔªËØµ÷ÓÃprintListº¯Êý
 & ......

ʹÓÃPython´¦ÀíExcel±í¸ñ

http://cocobear.info/blog/2009/01/16/use-python-deal-with-excel/
ʹÓÃPython´¦ÀíExcel±í¸ñ 2009Äê01ÔÂ16ÈÕ
¸ø°³µÄbossдµÄÒ»¸öС¹¤¾ß£¬Ê¹ÓÃPython¶ÔExcel½øÐÐͳ¼Æ£¬È»ºó°Ñ½áÊøÉú³ÉÒ»¸öеÄExcel±í¸ñ£¬Ê¹Óõ½ÁËxlrdºÍpyExceleratorÁ½¸ö¿â¡£
¼òµ¥µÄ½éÉÜÒ»ÏÂÕâÁ½¸ö¿â£¬ÏÈ˵xlrd£¬Õâ¸ö¿â¶ÁExcel±È½Ï·½±ã£¬¸÷ÖÖ·½·¨Ê¹ÓÃÆ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ