Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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¶¯Ì¬µ¼ÈëÄ£¿é¡¢¼ì²éÄ£¿éÊÇ·ñ°²×°

²Î¿¼Á´½Ó£ºhttp://www.woodpecker.org.cn/diveintopython/functional_programming/dynamic_import.html
Ò» ¶¯Ì¬µ¼ÈëÄ£¿é
PythonµÄimport²»ÄܽÓÊܱäÁ¿£¬ËùÒÔÓ¦¸ÃÓà __import__º¯ÊýÀ´¶¯Ì¬µ¼Èë¡£
ÈçϵĴúÂëÎÞ·¨Õý³£µ¼ÈëÄ£¿é
modules = ['OpenSSL', 'Crypto', 'MySQLdb', 'sqlite3', 'zope.interface', 'pyasn1', 'twisted ......

Python GTK+ ¿ª·¢Îĵµ

1. Building an Application with PyGTK and Glade
2. Creating a GUI using PyGTK and Glade
3. A Beginner's Guide to Using pyGTK and Glade
4. Is there a walkthrough on getting PyGTK2 and libglade2 to work on win32 ......

Python Import»úÖƱ¸Íü(ת)

Python Import»úÖƱ¸Íü(ת)
   ×î½üÔÚ¿´¡¶PythonÔ´ÂëÆÊÎö¡·£¬¶ÔPythonÄÚ²¿ÔËÐлúÖƱÈÒÔÇ°Á˽âµÄ¸üÉîÈëÁË£¬¸Ð¾õ×Ô¼ºÓлú»áÒ²¿ÉÒÔ×ö¸öСÐ͵Ķ¯Ì¬½Å±¾ÓïÑÔÁË£¬ºÇºÇ£¬µ±È»
ÊÇ´µÅ£ÁË¡£Ä¿µÄµ±È»²»ÊÇ´´ÔìÒ»¸ö¶¯Ì¬ÓïÑÔ£¬Ä¿µÄÖ»ÓÐÒ»¸ö£º¸üºÃµÄʹÓÃPython¡£¿´µ½Ä£¿éµ¼ÈëÄÇ¿éµÄʱºò£¬ÖÕÓÚ¶ÔÄ£¿éµ¼Èë»úÖƱȽÏÁ˽âÁË£¬ÒÔ·ÀÍ ......

python Excel ±à³Ì

1)Excel hyperlink:
xlsApp = win32com.client.Dispatch('Excel.Application')
cell = xls.App.ActiveSheet.Cells(1,1)
cell.Hyperlink.Add(cell,'http://xxx')
2)Excel row/column count:
sht = xlsApp.ActiveSheet
sht.Columns.Areas.Count
sht.Rows.Areas.Count
*************************
£Û1£ÝʹÓÃPyExcelera ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ