Created
November 16, 2022 19:17
How to Convert Excel to JPG in Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Excel to PNG in Nodejs | |
var aspose = aspose || {}; | |
aspose.cells = require("aspose.cells"); | |
// Initialize an instance of the workbook class and load the source file. | |
var wb = new aspose.cells.Workbook("sample.xlsx"); | |
// Create an object of the ImageOrPrintOptions class to access specific image creation options. | |
var imageOptions = new aspose.cells.ImageOrPrintOptions(); | |
// Call the setImageType method to set the image type. | |
imageOptions.setImageType(aspose.cells.ImageType.JPEG); | |
// The get(index) method will access the first worksheet in the workbook. | |
var Worksheet = wb.getWorksheets().get(0); | |
// Initialize the constructor of the SheetRender class for the target sheet. | |
var sheetRender = new aspose.cells.SheetRender(Worksheet, imageOptions); | |
// Loop through the pages and invoke the toImage method to create image for the sheet. | |
for (var j = 0; j < sheetRender.getPageCount(); j++) { | |
sheetRender.toImage(j, "ExcelToJPEG" + j + ".jpeg"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment