Rendern des Arbeitsblatts in einen Grafik Kontext mit Node.js via C++

Contents
[ ]

Der folgende Code veranschaulicht, wie man mit Aspose.Cells ein Arbeitsblatt in einen Grafik-Kontext rendert. Nach der Ausführung des Codes wird das gesamte Arbeitsblatt ausgegeben und der verbleibende leere Raum im Grafik-Kontext wird mit blauer Farbe ausgefüllt, und das Bild wird als **OutputImage_out_.png** gespeichert. Sie können jede Quelldatei Excel verwenden, um diesen Code auszuprobieren. Bitte lesen Sie auch die Kommentare im Code für ein besseres Verständnis.

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

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "SampleBook.xlsx");
// Create workbook object from source file
const workbook = new AsposeCells.Workbook(filePath);

// Access first worksheet
const worksheet = workbook.getWorksheets().get(0);

// Create empty image buffer
const bmpOptions = new AsposeCells.ImageOrPrintOptions();
bmpOptions.setOnePagePerSheet(true);

// Render worksheet to image
const sheetRender = new AsposeCells.SheetRender(worksheet, bmpOptions);
sheetRender.toImage(0, dataDir + "/OutputImage_out.png");

// Save the image in Png format