Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active August 7, 2021 23:07
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 aspose-cloud/469cf4440e231507387e77b78635064d to your computer and use it in GitHub Desktop.
Save aspose-cloud/469cf4440e231507387e77b78635064d to your computer and use it in GitHub Desktop.
This Gist contains code snippets related to conversion of XLS to PDF using Aspose.Cells Cloud SDK for Node.js
This Gist contains code snippets related to conversion of XLS to PDF using Aspose.Cells Cloud SDK for Node.js
const { CellsApi, CellsSaveAs_PostDocumentSaveAsRequest,UploadFileRequest,PdfSaveOptions } = require("asposecellscloud");
// Get your ClientId and ClientSecret from https://dashboard.aspose.cloud (free registration required).
const clientId = "718e4235-8866-4ebe-bff4-f5a14a4b6466";
const clientSecret = "388e864b819d8b067a8b1cb625a2ea8e";
// create an instnace of CellsApi
const cellsApi = new CellsApi(clientId, clientSecret);
// name of input Excel document
filename = "conditional.xlsx"
// include File System module reference in your code
const fs = require("fs");
// read the content of input Excel file
var data =fs.createReadStream("/Users/nayyershahbaz/Downloads/"+ filename);
// create FileUpload Request instance
var req = new UploadFileRequest();
req.path = filename;
// set the content as Stream instance containing loaded Excel file
req.file = data;
// Upload the file to cloud storage
return cellsApi.uploadFile(req)
.then((result) => {
// Create Document SaveAsRequest instance
var req = new CellsSaveAs_PostDocumentSaveAsRequest();
req.name = filename;
// Create an object of PdfSaveOptions class
req.saveOptions = new PdfSaveOptions();
// set the resultant file format as PDF
req.saveOptions.saveFormat = "pdf";
// set the name for new resultant file
req.newfilename = "newbook.pdf";
// since we are going to save in default location, so we will set null as folder value
req.folder = null;
// Call the SaveAsPostDocument method to initiate the conversion process
return cellsApi.cellsSaveAsPostDocumentSaveAs(req)
.then((result) => {
expect(result.body.code).to.equal(200);
expect(result.response.statusCode).to.equal(200);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment