-1

I have started with pyhton and pandas today only and I am a noob coder, so please explain in detail. I have got this kind of code from add hyperlink to excel sheet created by pandas dataframe to_excel method

df = pd.DataFrame({'link':['=HYPERLINK("http://www.someurl.com", "some website")']})

but I dont understand to which column is it adding the link to and I have to add such that I mention ony column and It should take the value of link itself from that column.

Community
  • 1
  • 1
  • 1
    I think first check http://pandas.pydata.org/pandas-docs/stable/10min.html and then this [answer](http://stackoverflow.com/a/31821781/2901002). – jezrael May 24 '16 at 08:24

1 Answers1

0

I am able to figure this out myself, took quite a long time though

workbook = xlrd.open_workbook('test.xlsx')

worksheet = workbook.sheet_by_index(0)

workbook1 = load_workbook('pandas.xlsx')

worksheet1 = workbook1.active column_indices = [12] #my hyperlinks are in 12th column

for row in range(1,worksheet.nrows):

for col in column_indices:
    filelocation = worksheet.cell_value(row, col)
    text = worksheet.cell_value(row, col+2)
    worksheet1.cell(row=row+1, column=col-3).value = '=HYPERLINK("'+filelocation+'","'+text+'")'

workbook1.save('pandas_simple.xlsx')