範囲内のハイパーリンクを取得
Contents
[
Hide
]
範囲内のハイパーリンクを取得
Rangeクラスは、選択範囲内のすべてのハイパーリンクを返すgetHyperlinks()メソッドを提供します。また、Hyperlink.delete()メソッドを呼び出してハイパーリンクを削除することも可能です。
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
const path = require("path"); | |
const AsposeCells = require("aspose.cells.node"); | |
// The path to the documents directory. | |
const sourceDir = path.join(__dirname, "data"); | |
const outputDir = path.join(__dirname, "output"); | |
// Instantiate a Workbook object | |
// Open an Excel file | |
const workbook = new AsposeCells.Workbook(`${sourceDir}/HyperlinksSample.xlsx`); | |
// Get the first (default) worksheet | |
const worksheet = workbook.getWorksheets().get(0); | |
// Create a range A2:B3 | |
const range = worksheet.getCells().createRange("A2", "B3"); | |
// Get Hyperlinks in range | |
const hyperlinks = range.getHyperlinks(); | |
hyperlinks.forEach(link => { | |
console.log(`${link.getArea()} : ${link.getAddress()}`); | |
// To delete the link, use the Hyperlink.Delete() method. | |
link.delete(); | |
}); | |
workbook.save(`${outputDir}/HyperlinksSample_out.xlsx`); |