Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
You can make an image of a worksheet using Aspose.Cells for Node.js via C++. However, sometimes you need to export only a range of cells in a worksheet to an image. This article explains how to achieve this.
To take an image of a range, set the print area to the desired range and then set all margins to 0. Also set ImageOrPrintOptions.getOnePagePerSheet() to true. The following code takes an image of the range D8:G16. Below is a screenshot of the sample Excel file used in the code. You can try the code with any Excel file.

Executing the code creates an image of the range D8:G16 only.

const path = require("path");
const AsposeCells = require("aspose.cells.node");
// Source directory
const sourceDir = path.join(__dirname, "data");
// Output directory
const outputDir = path.join(__dirname, "output");
// Create workbook from source file.
const workbook = new AsposeCells.Workbook(path.join(sourceDir, "sampleExportRangeOfCellsInWorksheetToImage.xlsx"));
// Access the first worksheet
const worksheet = workbook.getWorksheets().get(0);
// Set the print area with your desired range
worksheet.getPageSetup().setPrintArea("D8:G16");
// Set all margins to 0
worksheet.getPageSetup().setLeftMargin(0);
worksheet.getPageSetup().setRightMargin(0);
worksheet.getPageSetup().setTopMargin(0);
worksheet.getPageSetup().setBottomMargin(0);
// Set the OnePagePerSheet option to true
const options = new AsposeCells.ImageOrPrintOptions();
options.setOnePagePerSheet(true);
options.setImageType(AsposeCells.ImageType.Jpeg);
options.setHorizontalResolution(200);
options.setVerticalResolution(200);
// Capture the image of your worksheet
const sr = new AsposeCells.SheetRender(worksheet, options);
sr.toImage(0, path.join(outputDir, "outputExportRangeOfCellsInWorksheetToImage.jpg"));
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.