Inserisci immagine di sfondo in Excel con Node.js tramite C++
Impostare lo sfondo del foglio in Microsoft Excel
Impostare un’immagine di sfondo di un foglio in Microsoft Excel (ad esempio, Microsoft Excel 2019):
-
Dal menu Layout di pagina, individuare l’opzione Imposta pagina e fare clic sull’opzione Sfondo.
-
Seleziona un’immagine da impostare come sfondo del foglio.
Impostazione di uno sfondo del foglio
Impostare lo sfondo del foglio con Aspose.Cells for Node.js via C++
Il codice di seguito imposta un’immagine di sfondo utilizzando un’immagine da un flusso.
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);