更改HTML链接的目标类型
Contents
[
Hide
]
Aspose.Cells 允许您更改 HTML 链接的目标类型。 HTML 链接看起来像这样
<a href="http://www.aspose.com/" target="_self">
如您所见,上述HTML链接中的target属性是**_self**。您可以使用HtmlSaveOptions.LinkTargetType属性来控制此target属性。此属性采用了HtmlLinkTargetType枚举,其具有以下值。
- HtmlLinkTargetType.Blank
- HtmlLinkTargetType.Parent
- HtmlLinkTargetType.Self
- HtmlLinkTargetType.Top
以下代码说明了 HtmlSaveOptions.LinkTargetType 属性的用法。 它将链接目标类型更改为 blank。 默认情况下,它是 parent。
This file contains hidden or 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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
string inputPath = dataDir + "Sample1.xlsx"; | |
string outputPath = dataDir + "Output.out.html"; | |
Workbook workbook = new Workbook(dataDir + "Sample1.xlsx"); | |
HtmlSaveOptions opts = new HtmlSaveOptions(); | |
opts.LinkTargetType = HtmlLinkTargetType.Self; | |
workbook.Save(outputPath, opts); | |
Console.WriteLine("File saved: {0}", outputPath); |