Infoga bakgrundsbild i Excel med Node.js via C++

Ange bakgrund på kalkylblad i Microsoft Excel

För att ange ett kalkylblads bakgrundsbild i Microsoft Excel (t.ex. Microsoft Excel 2019):

  1. Från menyn Sidlayout, hitta alternativet Sidlayout och klicka sedan på alternativet Bakgrund.

  2. Välj en bild för att sätta kalkylbladets bakgrundsbild.

    Ange en ark-bakgrund

todo:image_alt_text

Ställa in bladbakgrund med Aspose.Cells for Node.js via C++

Koden nedan ställer in en bakgrundsbild med en bild från en ström.

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);

Relaterade artiklar