Extracting Hyperlinks From Excel (.xlsx) with Python -
i have been looking @ xlrd , openpyxl libraries excel file manipulation. however, xlrd not support formatting_info=true .xlsx files, can not use xlrd hyperlink_map function. turned openpyxl, have had no luck extracting hyperlink excel file it. test code below (the test file contains simple hyperlink google hyperlink text set "test"):
import openpyxl wb = openpyxl.load_workbook('testfile.xlsx') ws = wb.get_sheet_by_name('sheet1') r = 0 c = 0 print ws.cell(row = r, column = c). value print ws.cell(row = r, column = c). hyperlink print ws.cell(row = r, column = c). hyperlink_rel_id output:
test none i guess openpyxl not support formatting either? there other library can use extract hyperlink information excel (.xlsx) files?
in experience getting .xlsx interaction requires moving ironpython. lets work common language runtime (clr) , interact directly excel'
import clr clr.addreference("microsoft.office.interop.excel") import microsoft.office.interop.excel excel excel = excel.applicationclass() wb = excel.workbooks.open('testfile.xlsx') ws = wb.worksheets['sheet1'] address = ws.cells(row, col).hyperlinks.item(1).address
Comments
Post a Comment