It is strange that when loading excel exists with openpyxl and saves it again, the hyperlinks in the file disappear.
Either openpyxl 1.7.2 or the latest version 1.8.5 has this problem.
Can anyone help with this issue?
Or is there a better choice than openpyxl?
I know xlrd / xlwt and XlsxWriter, but xlwt does not support .xlsx files, and XlsxWriter cannot read existing files. I need to change the file many times in my application.
[UPDATED]: Look here . It seems that the error has not yet been fixed?
The following code may be useful for your test.
import openpyxl
def create():
wb = openpyxl.Workbook()
ws = wb.worksheets[0]
ws.cell('A1').value = 'Click Me'
ws.cell('A1').hyperlink = 'http://www.google.com'
wb.save('test1.xlsx')
def rewrite():
wb = openpyxl.load_workbook('test1.xlsx')
ws = wb.worksheets[0]
wb.save('test2.xlsx')
if __name__ == '__main__':
create()
rewrite()
[2017-03-07 UPDATED]: the error has been fixed and the problem no longer exists.