Hyperlinks aus Excel extrahieren mit Python
Hier ist ein kleines Python-Script, welches alle Hyperlinks aus Microsoft Excel Dokumenten in eine Textdatei extrahiert. Es benötigt Pywin32!
from win32com.client import Dispatch
from sys import argv
from sys import exit
if len(argv)<=2:
print 'This tool extracts all Hyperlink addresses from Excel documents to a file..'
print '\nUsage: xlshyperlink.exe '
exit()
app = Dispatch('Excel.Application')
app.Visible = 0
doc = app.Workbooks.Open(argv[1], 0, False, 2)
file = open(argv[2], 'w')
count = 0
for i in range (doc.Worksheets.Count):
for worksheet in range (doc.Worksheets.Item(i+1).Hyperlinks.Count):
link = doc.Worksheets.Item(i+1).Hyperlinks.Item(worksheet+1).Address
file.write(link+'\n')
print link
count += 1
file.close()
print 'Written %s URLS to file %s'%(count, argv[2])
doc.Saved = 1
app.Quit()