Heben Sie Hintergrundbild in Excel mit Node.js über C++ ein
Blatthintergrund in Microsoft Excel festlegen
Um ein Hintergrundbild für ein Blatt in Microsoft Excel festzulegen (z. B. Microsoft Excel 2019):
-
Wählen Sie im Menü Seitenlayout die Option Seiteneinrichtung und anschließend die Option Hintergrund.
-
Wählen Sie ein Bild aus, um das Hintergrundbild des Blatts festzulegen.
Festlegen eines Blatthintergrunds
Hintergrundbild im Arbeitsblatt mit Aspose.Cells for Node.js via C++ einstellen
Der unten stehende Code legt ein Hintergrundbild mithilfe eines Bildes aus einem Stream fest.
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);