简体   繁体   English

如何在excel中创建超链接以通过python在特定页面中打开word文件

[英]How to create a hyperlink in excel to open word file in specific page by python

Here is a document(word file), and I extract some sentences from that and write into an excel file by python.这是一个文档(word文件),我从中提取了一些句子并通过python写入excel文件。

And now I want to create a hyperlink of a sentences, which links to the page where the sentences belong.现在我想创建一个句子的超链接,它链接到句子所属的页面。

For example, if there a sentence "I love python" is in page 5 in a word file, and after I extract this sentence to a cell of an excel file by python, it is possible to create a hyperlink linking back to page 5 of that word file by xlsxwriter?例如,如果一个word文件的第5页有一句话“我爱python”,我把这句话用python提取到excel文件的一个单元格后,就可以创建一个链接回到第5页的超链接xlsxwriter 的那个 word 文件?

I afraid there is no way you can hyperlink to a page in DOCS file.恐怕您无法超链接到 DOCS 文件中的页面。 You can hyperlink till file level.您可以超链接到文件级别。

Attaching the code here.在这里附上代码。

formula = 'HYPERLINK("[{path]", "Click Here")'.format(path=<PATH TO FILE>)
value = xlwt.Formula(formula)

This is done by xlwt library.这是由 xlwt 库完成的。 Also, The Hyperlink works differently on different excel formats.此外,超链接在不同的 excel 格式上的工作方式不同。 ie Hyperlink works on Microsoft excel will not work in Open Office Excel.即超链接在 Microsoft excel 上工作在 Open Office Excel 中不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Excel文件中获取指向PDF中特定页面的超链接 - Getting a hyperlink inside an excel file that directs to a specific page in a PDF 如何使用 Python 将粗体样式应用于 Excel 文件中的特定单词? - How to apply bold style to a specific word in Excel file using Python? Python:在Excel文件中查找特定的单词或值 - Python: Looking for specific word or values in an excel file Excel超链接不起作用“无法打开指定的文件” - Excel hyperlink not working "cannot open the specified file" 使用 python 创建一个超链接,指向 ms office word 中的特定书签。 (叶子地图标记点) - use python to create a hyperlink leading to a specific bookmark at ms office word. ( folium map marker point) Python - 打开 pdf 文件到特定页面/部分 - Python - open pdf file to specific page/section 如何打开文本文件并查找在一行中的特定单词和 append 文件名之后写入的内容到 Python 中的列表 - How to open a text file and find what is written after a specific word in a line and append that files name to a list in Python 如何在Python中的文本文件中搜索特定单词 - How to search a text file for a specific word in Python 如何删除 python 中文件名中包含特定单词的文件 - How to delete a file with a specific word in the filename in python 在python中添加超链接到Excel csv文件 - Add Hyperlink to Excel csv file in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM