|
const { CellsApi, UploadFileRequest, CellsOleObjects_PutWorksheetOleObjectRequest } = require("asposecellscloud"); |
|
const clientId = process.env.CellsCloudClientId; |
|
const clientSecret = process.env.CellsCloudClientSecret; |
|
const ApiURL = process.env.CellsCloudApiBaseUrl; |
|
const fs = require('fs'); |
|
const path = require('path'); |
|
const cellsApi = new CellsApi(clientId, clientSecret,"v3.0",ApiURL); |
|
const localPath = "D:/aspose-cells-cloud-node/TestData/" |
|
|
|
const filename = "Book1.xlsx"; |
|
const filename1 = "OLEDoc.docx"; |
|
const filename2 = "word.jpg"; |
|
const data =fs.createReadStream(path.join(localPath, filename)); |
|
|
|
const req = new UploadFileRequest({ |
|
path: "Temp/" + filename, |
|
file: data |
|
}); |
|
cellsApi.uploadFile(req) |
|
.then((result) => { |
|
const filename1= "word.jpg"; |
|
const cellsApi = new CellsApi(clientId, clientSecret,"v3.0",ApiURL); |
|
const data =fs.createReadStream(localPath + filename1); |
|
const req = new UploadFileRequest(); |
|
req.path = "Temp/" + filename1; |
|
req.file = data; |
|
cellsApi.uploadFile(req) |
|
.then((result) => { |
|
const filename2 = "OLEDoc.docx"; |
|
const cellsApi = new CellsApi(clientId, clientSecret,"v3.0",ApiURL); |
|
const data =fs.createReadStream(localPath + filename2); |
|
const req = new UploadFileRequest(); |
|
req.path = "Temp/" + filename2; |
|
req.file = data; |
|
cellsApi.uploadFile(req) |
|
.then((result) => { |
|
const req = new CellsOleObjects_PutWorksheetOleObjectRequest(); |
|
req.name = filename; |
|
req.sheetName = "Sheet6"; |
|
req.folder = "Temp"; |
|
req.oleObject = null; |
|
req.upperLeftRow = 1; |
|
req.upperLeftColumn = 1; |
|
req.height = 100; |
|
req.width = 80; |
|
req.oleFile = filename1; |
|
req.imageFile = filename2; |
|
cellsApi.cellsOleObjectsPutWorksheetOleObject(req) |
|
.then((result) => { |
|
console.log("successful") |
|
|
|
}) |
|
|
|
|
|
}) |
|
}) |
|
|
|
|
|
}) |
|
.catch((error) => { |
|
console.error('Unhandled Promise Rejection:', error); |
|
}) |