Change the HTML Link Target Type
Contents
[
Hide
]
Aspose.Cells allows you to change the HTML link target type. HTML link looks like this :
<a href="http://www.aspose.com/" target="_self">
As you can see the target attribute in the above HTML link is _self. You can control this target attribute using the HtmlSaveOptions.setLinkTargetType() property. This property takes the HtmlLinkTargetType enum which has the following values.
Change the HTML Link Target Type
The following code illustrates the usage of HtmlSaveOptions.setLinkTargetType() property. It changes the link target type to blank. By default, it is the parent. You can get the source excel file from this link however you can use any excel file which contains an HTML hyperlink inside it to run this code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ChangeHTMLLinkTargetType.class); | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
HtmlSaveOptions opts = new HtmlSaveOptions(); | |
opts.setLinkTargetType(HtmlLinkTargetType.SELF); | |
workbook.save(dataDir + "out.html", opts); |