Skip to content

Instantly share code, notes, and snippets.

@mustafabutt-dev
Created April 26, 2022 03:09
Show Gist options
  • Save mustafabutt-dev/04bb689cc441f60d0e909e78964a9e12 to your computer and use it in GitHub Desktop.
Save mustafabutt-dev/04bb689cc441f60d0e909e78964a9e12 to your computer and use it in GitHub Desktop.
code snippet to import XML data into Excel
// create sheet from stream(e.g. xml to xlsx)
var aspose = aspose || {};
//get the aspose.cells module in to your project.
aspose.cells = require("aspose.cells");
// load the fs module for reading/writing files
var fs = require("fs");
// creates the read stream of the source file
var readStream = fs.createReadStream("myxml.xml");
// accepts the data stream and populates/import XML data into Excel file
aspose.cells.Workbook.createWorkbookFromStream(readStream, function(workbook, err) {
if (err) {
console.log("open workbook error");
return;
}
// save the file
workbook.save('result.xlsx');
console.log('Successfully imported XML file to Excel');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment