[英]Export Excel file to PDF format without loosing hyperlink functionality
I use the following code to read in an Excel file and export select sheets to a PDF:我使用以下代码读取 Excel 文件并将 select 工作表导出到 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.在 Excel 文件中,我有在工作表之间切换的超链接,但这些链接失去了 PDF 格式的功能。 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?我的问题是是否有任何方法可以保留 PDF 形式的链接功能?
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:这不是一件简单的事情,格式可能是个问题,但如果您在 Excel 文件中拥有的是带有文本和数字的简单表格(没有图像或花哨的格式),则可能有一种使用 LaTeX 的方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.