This article describes how to edit Excel Hyperlinks in documents , Including editing hyperlinks to display text 、 Link address and delete the specified hyperlink . Use Free version Excel Class library tools ,Free Spire.XLS for Java.Jar Packages are available on the official website download , And unzip will lib Under folder jar Import Java Program ;Maven In program jar Import reference to this article course .
Refer to the following jar Import results :
1. Edit hyperlink
import com.spire.xls.*; import com.spire.xls.collections.HyperLinksCollection; public class ModifyHyperlink { public static void main(String[] args) { // load Excel Test documentation Workbook wb = new Workbook(); wb.loadFromFile("test.xlsx"); // Get the specified worksheet Worksheet sheet = wb.getWorksheets().get(0); // Get hyperlinks , Modify hyperlinks to this article 、 Link address HyperLinksCollection link = sheet.getHyperLinks(); link.get(0).setTextToDisplay(" New hyperlinks show text "); link.get(0).setAddress("https://cn.bing.com/"); // Save the document wb.saveToFile("ModifyHyperlink.xlsx"); wb.dispose(); } }
2. Remove hyperlinks
import com.spire.xls.*; public class RemoveHyperlink { public static void main(String[] args) { // Load... Containing hyperlinks Excel file Workbook workbook = new Workbook(); workbook.loadFromFile("AddHyperlink.xlsx"); // Get the first sheet Worksheet sheet = workbook.getWorksheets().get(0); // Remove hyperlinks , And keep the text information sheet.getHyperLinks().removeAt(0); // Save the document workbook.saveToFile("RemoveHyperlink.xlsx", ExcelVersion.Version2013); workbook.dispose(); } }
Recommended articles :Java Add hyperlink to Excel file