Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created August 14, 2022 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conholdate-gists/ccbc6dcb52280b9ded1d0fccfaf3041a to your computer and use it in GitHub Desktop.
Save conholdate-gists/ccbc6dcb52280b9ded1d0fccfaf3041a to your computer and use it in GitHub Desktop.
Convert Excel to SVG in Node.js
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