Created
August 14, 2022 18:15
-
-
Save conholdate-gists/ccbc6dcb52280b9ded1d0fccfaf3041a to your computer and use it in GitHub Desktop.
Convert Excel to SVG 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
var aspose = aspose || {}; | |
aspose.cells = require("aspose.cells"); | |
// Create a workbook object and load the source file | |
var workbook = new aspose.cells.Workbook("sample.xlsx"); | |
// Initialize an instance of the ImageOrPrintOptions class to access additional image creation options | |
var imgOptions = new aspose.cells.ImageOrPrintOptions(); | |
// Convert each worksheet into svg format in a single page by calling setSaveFormat method | |
imgOptions.setSaveFormat(aspose.cells.SaveFormat.SVG); | |
// Invoke this setOnePagePerSheet method to put all content of one sheet to only one page. | |
imgOptions.setOnePagePerSheet(true); | |
var sheetCount = workbook.getWorksheets().getCount(); | |
for (var i = 0; i < sheetCount; i++) { | |
var sheet = workbook.getWorksheets().get(i); | |
// Convert each worksheet into svg format by calling SheetRender method | |
var sr = new aspose.cells.SheetRender(sheet, imgOptions); | |
for (var k = 0; k < sr.getPageCount(); k++) { | |
// Call this toImage method to output the worksheet into Svg image format | |
sr.toImage(k, sheet.getName() + k + "_out.svg"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment