NodeJS API to protect local Microsoft Excel and OpenOffice Calc spreadsheet with password
NodeJS library to protect local Microsoft Excel and OpenOffice Calc spreadsheet with password
Protect local Microsoft Excel and OpenOffice Calc spreadsheet with password - NodeJS REST API
API Request:
POST
https://api.aspose.cloud/v3.0/cells/protect
Protecting a local spreadsheet with a password is a complex task. Protecting a local spreadsheet with password transitions is performed by our NodeJS SDK while maintaining the source spreadsheet's main structural and logical content. Our NodeJS library is a professional solution to protect local spreadsheets with a password online. This Cloud SDK gives NodeJS developers powerful functionality and perfect API.
Code example in Node using REST API to encryption local spreadsheets
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
// For complete examples and data files, please go to https://github.com/aspose-cells-cloud/aspose-cells-cloud-node/ | |
const { LightCellsApi, PostProtectRequest } = require("asposecellscloud"); | |
const clientId = process.env.CellsCloudClientId; | |
const clientSecret = process.env.CellsCloudClientSecret; | |
const ApiURL = process.env.CellsCloudApiBaseUrl; | |
const cellsApi = new LightCellsApi(clientId, clientSecret,"v3.0",ApiURL); | |
const fs = require('fs'); | |
const path = require('path'); | |
const localPath = "D:/aspose-cells-cloud-node/TestData/" | |
const AssemblyTestXlsx = "assemblytest.xlsx"; | |
const DataSourceXlsx = "datasource.xlsx"; | |
const dataAssemblyTestXlsx = fs.createReadStream(path.join(localPath, AssemblyTestXlsx)); | |
const dataDataSourceXlsx = fs.createReadStream(path.join(localPath, DataSourceXlsx)); | |
const req = new PostProtectRequest({ | |
file: { AssemblyTestXlsx: dataAssemblyTestXlsx, DataSourceXlsx: dataDataSourceXlsx }, | |
password : "123456" | |
}); | |
cellsApi.postProtect(req) | |
.then((result) => { | |
console.log("successfully") | |
const buff = Buffer.from(result.body.files[0].fileContent, 'base64'); | |
fs.writeFileSync(result.body.files[0].filename, buff); | |
}) | |
.catch((error) => { | |
console.error('Unhandled Promise Rejection:', error); | |
}); |
How to use Node API to encrypt
- Create an account at Dashboard to get free API quota & authorization details
- Initialize CellsApi with Client Id, Client Secret, Base URL & API version
- Call postProtect method to get the resultant stream
System Requirements
- node v6.17.1 or newer