Webアドレスからリンクされた画像をNode.js経由でC++で挿入
Contents
[
Hide
]
時には、ウェブ(http://)から画像をワークシートに挿入する必要があります。その場合、画像のURLを指定すると、そのスプレッドシートをExcelで開くたびに画像がダウンロードされます。画像はExcelドキュメントに物理的に埋め込まれるのではなく、ウェブリソースを指し示します。
Microsoft Excel の使用
Microsoft Excel(たとえば2007)で:
- 挿入メニューをクリックし、画像を選択します。
- 挿入画像ダイアログで画像のWebアドレスを指定します。
Aspose.Cells for Node.js via C++を使用して
Aspose.Cells for Node.js via C++は、ShapeCollection.addLinkedPicture(upperLeftRow, upperLeftColumn, heightPixels, widthPixels, sourceFullName)を使用したリンク画像の追加をサポートします。この方法はPictureオブジェクトを返します。
以下の例では、Webアドレスからリンクされた画像をワークシートに追加する方法を示しています。
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
// Instantiate a new Workbook.
const workbook = new AsposeCells.Workbook();
// Insert a linked picture (from Web Address) to B2 Cell.
const pic = workbook.getWorksheets().get(0).getShapes().addLinkedPicture(1, 1, 100, 100, "http://www.aspose.com/Images/aspose-logo.jpg");
// Set the height and width of the inserted image.
pic.setHeightInch(1.04);
pic.setWidthInch(2.6);
// Save the Excel file.
workbook.save(path.join(dataDir, "outLinkedPicture.out.xlsx"));