Node.jsとC++を使ったExcelへ背景画像の挿入方法。

Microsoft Excelでのシートの背景の設定方法(例:Microsoft Excel 2019):

  1. ページレイアウトメニューからページの設定オプションを見つけ、背景オプションをクリックします。

  2. ページレイアウトメニューからページ設定オプションを見つけ、背景オプションをクリックします。

  3. シートの背景画像を設定するために画像を選択します。

    シートの背景を設定する

todo:image_alt_text

シートの背景設定とAspose.Cells for Node.js via C++による設定

以下のコードは、ストリームから画像を使用して背景画像を設定します。

const fs = require("fs");
const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const backgroundImagePath = path.join(dataDir, "background.jpg");

// Create a new Workbook.
const workbook = new AsposeCells.Workbook();

// Get the first worksheet.
const sheet = workbook.getWorksheets().get(0);

// Set the background image for the worksheet.
sheet.setBackgroundImage(fs.readFileSync(backgroundImagePath).buffer);

// Save the Excel file
workbook.save("outputBackImageSheet.xlsx");

// Save the HTML file
workbook.save("outputBackImageSheet.html", AsposeCells.SaveFormat.Html);

関連記事