使用Node.js通过C++更改HTML链接的目标类型
Contents
[
Hide
]
Aspose.Cells 允许您更改 HTML 链接的目标类型。 HTML 链接看起来像这样
<a href="http://www.aspose.com/" target="_self">
如你所见,上述HTML链接中的target属性是**_self**。你可以使用HtmlSaveOptions.getLinkTargetType()属性控制这个target属性。此属性接受具有以下值的HtmlLinkTargetType枚举。
- HtmlLinkTargetType.Blank
- HtmlLinkTargetType.Parent
- HtmlLinkTargetType.Self
- HtmlLinkTargetType.Top
以下代码说明了HtmlSaveOptions.getLinkTargetType()属性的用法。它将链接目标类型更改为blank。默认值是parent。
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const inputPath = path.join(dataDir, "Sample1.xlsx");
const outputPath = path.join(dataDir, "Output.out.html");
const workbook = new AsposeCells.Workbook(inputPath);
const opts = new AsposeCells.HtmlSaveOptions();
opts.setLinkTargetType(AsposeCells.HtmlLinkTargetType.Self);
workbook.save(outputPath, opts);
console.log(`File saved: ${outputPath}`);