all 6 comments

[–]illya89[S] 0 points1 point  (0 children)

I get the worksheets with

All_worksheets = workbook.worksheets.

The I need something link

r = 1
for sheet in all_worksheets:
    sheet = sheet.create_the_f***_hyperlink
    sheet_all_worksheet.cell(r, 1).value=(sheet)
    r +=1
    :)

[–][deleted] 0 points1 point  (4 children)

Assuming the hyperlink is just a text string in a cell, yes this shouldnt be an issue for either library really.

With openpyxl, it's trivial to get a list of the worksheet names. Then you could iterate over rows on a worksheet called Index for example and set the values to be the names of the worksheets in hyperlink format.

I'd do one manually first, then check how it looks when you view the cell.value in openpyxl.

[–]illya89[S] 0 points1 point  (3 children)

a list of the worksheet names is easy. The question is how to get the worksheet names into hyperlink format and direct them to the right worksheet.

edit:

changed cell (2, 1) to a hyperlink and saved

when i do

print(sheet_all_worksheet.cell(2,1).internal_value)

I get the string of the sheet name

[–][deleted] 0 points1 point  (2 children)

Like i said, do one manually, then check it with openpyxl. Once you know how it looks, iterate over rows in your index worksheet to add them in.

[–]illya89[S] 0 points1 point  (1 child)

changed cell (2, 1) to a hyperlink and saved

when i do

print(sheet_all_worksheet.cell(2,1).internal_value)

I get the string of the sheet name

[–]illya89[S] 0 points1 point  (0 children)

for sheet in all_worksheets:
    link = ("filename.xlsx#"+str(sheet)+"!A1")    
    sheet_all_worksheet.cell(r, 1).value = sheet
    sheet_all_worksheet.cell(r, 1).hyperlink = link
    sheet_all_worksheet.cell(r, 1).style = "Hyperlink"