简体   繁体   English

如何通过Java / groovy在Excel中设置超链接的相对路径

[英]How to set relative path for a hyperlink in Excel through Java/groovy

I have a directory there I have one Excel file and one text file. 我在那里有一个目录,我有一个Excel文件和一个文本文件。 I want to set a hyperlink in my Excel for that text file with relative path. 我想在Excel中为带有相对路径的文本文件设置超链接。 Wherever I can store that directory in my system and that hyperlink should work. 只要将目录存储在系统中的任何位置,该超链接都应该起作用。

Problem: If I am setting absolute path for the text file in the hyperlink then it creates problem when I change the directory location. 问题:如果我要为超链接中的文本文件设置绝对路径,则在更改目录位置时会产生问题。

So I want to set a relative path for the hyperlink so wherever I store my directory the hyperlink should work because my both files are stored inside one parent directory. 因此,我想为超链接设置一个相对路径,以便在我将目录存储到任何地方时,超链接都应该起作用,因为我的两个文件都存储在一个父目录中。

got the solution String relativePath = "../parentdir/fileToLink.txt"; 得到了解决方案String relativePath = "../parentdir/fileToLink.txt";

If this path get set there then its working fine. 如果在此设置此路径,则可以正常工作。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM