Reputation: 986
I use the following code to read in an Excel file and export select sheets to a PDF:
import win32com.client
xlsx_path = "" #insert path to excel file
pdf_path = "" #insert path to pdf output
excel = win32com.client.gencache.EnsureDispatch("Excel.Application")
wb = excel.Workbooks.Open(xlsx_path)
sheet_list = ["Sheet1", "Sheet2"]
wb.Worksheets(sheet_list).Select()
wb.ActiveSheet.ExportAsFixedFormat(0, pdf_path)
wb.Close()
Within the Excel file I have hyperlinks that toggle between the sheets, but the links loose their functionality in PDF format. An example of the macro I use is:
=HYPERLINK("[file.xlsx]Sheet1!A1","back")
My question is if there is any way to preserve the links functionality in PDF form?
Upvotes: 2
Views: 360
Reputation: 4129
This isn't exactly something simple and formatting might be an issue, but if what you have in your Excel file are simple tables with text and numbers (without images or fancy formatting), there might be a way using LaTeX:
Upvotes: 1