Skip to content

Commit

Permalink
New Feature Implementation for Aspose.Cells
Browse files Browse the repository at this point in the history
Convert Excel Workbook with Additional Settings
Split Excel Workbooks
Get AutoShape from a Worksheet
Sort Worksheet Data
Copy Excel Worksheet
Rename Excel Worksheet
Update Excel Worksheet Properties
Set Background or Watermark for Excel Worksheet
Freeze Panes in Excel Worksheet
Unfreeze Panes in Excel Worksheet
Delete Background or Watermark of Excel Worksheet
  • Loading branch information
assadvirgo committed Jun 8, 2015
1 parent 4a653e4 commit 7dd23dd
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 1 deletion.
258 changes: 258 additions & 0 deletions lib/aspose-cells.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var path = require('path');
* @type {exports}
*/
var fs = require('fs');
var qs = require('querystring');
/**
*
* @type {AsposeStorage|exports}
Expand All @@ -32,6 +33,76 @@ function AsposeCells(config) {

/* Worksheet Methods */

AsposeCells.prototype.sortData = function(fileName,worksheetName,cellArea,sortOrder,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
cellArea = typeof cellArea !== 'undefined' ? cellArea : '';
sortOrder = typeof sortOrder !== 'undefined' ? sortOrder : '';

if(fileName === '' || worksheetName === '' || sortOrder === '' || cellArea === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName + '/sort?cellArea=' + cellArea;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('POST',signedURI,sortOrder,function(data){
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
throw new Error(data.Message);
}
}
});
};

AsposeCells.prototype.copyWorksheet = function(fileName,worksheetName,newName,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
newName = typeof newName !== 'undefined' ? newName : '';

if(fileName === '' || worksheetName === '' || newName === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + newName + '/copy?sourcesheet=' + worksheetName;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('POST',signedURI,sortOrder,function(data){
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
throw new Error(data.Message);
}
}
});
};

AsposeCells.prototype.renameWorksheet = function(fileName,worksheetName,newName,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
newName = typeof newName !== 'undefined' ? newName : '';

if(fileName === '' || worksheetName === '' || newName === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName + '/Rename?newname=' + newName;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('POST',signedURI,sortOrder,function(data){
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
throw new Error(data.Message);
}
}
});
};

AsposeCells.prototype.getCellStyle = function(fileName,worksheetName,cellName,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
Expand Down Expand Up @@ -196,6 +267,102 @@ AsposeCells.prototype.setCellValue = function(fileName,worksheetName,cellName,va
});
};

AsposeCells.prototype.setBackgroundImage = function(fileName,worksheetName,imageFilename,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
imageFilename = typeof imageFilename !== 'undefined' ? imageFilename : '';

if(fileName === '' || worksheetName === '' || imageFilename === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName + '/Background?imageFile=' + imageFilename;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('PUT',signedURI,'',function(data){
console.log(data);
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
callback.call(null,data);
}
}
});
};

AsposeCells.prototype.deleteBackgroundImage = function(fileName,worksheetName,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';

if(fileName === '' || worksheetName === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName + '/Background';
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('DELETE',signedURI,'',function(data){
console.log(data);
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
callback.call(null,data);
}
}
});
};

AsposeCells.prototype.freezePanes = function(fileName,worksheetName,options,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
options = typeof options !== 'undefined' ? options : '';

if(fileName === '' || worksheetName === '' || options === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName + '/FreezePanes';
strURI = strURI + '?' + qs.stringify(options);
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('PUT',signedURI,'',function(data){
console.log(data);
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
callback.call(null,data);
}
}
});
};

AsposeCells.prototype.unfreezePanes = function(fileName,worksheetName,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';

if(fileName === '' || worksheetName === '' ){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName + '/FreezePanes';
strURI = strURI + '?' + qs.stringify(options);
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('DELETE',signedURI,'',function(data){
console.log(data);
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
callback.call(null,data);
}
}
});
};

AsposeCells.prototype.calculateFormula = function(fileName,worksheetName,formula,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
Expand Down Expand Up @@ -716,6 +883,28 @@ AsposeCells.prototype.mergeWorkbook = function(fileName,mergewithFilename,callba
});
};

AsposeCells.prototype.splitWorkbook = function(fileName,saveFormat,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
saveFormat = typeof saveFormat !== 'undefined' ? saveFormat : '';

if(fileName === '' || saveFormat === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/split?format=' + saveFormat;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('POST',signedURI,'',function(data){
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
throw new Error(data.Message);
}
}
});
};

AsposeCells.prototype.removeWorksheet = function(fileName,worksheetName,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
Expand Down Expand Up @@ -1088,6 +1277,29 @@ AsposeCells.prototype.removeProperties = function(fileName,callback){
});
};

AsposeCells.prototype.updateProperties = function(fileName,worksheetName,properties,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
properties = typeof properties !== 'undefined' ? properties : '';

if(fileName === '' || worksheetName === '' || properties === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandContent('POST',signedURI,properties,function(data){
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
throw new Error(data.Message);
}
}
});
};

AsposeCells.prototype.removeProperty = function(fileName,propertyName,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
propertyName = typeof propertyName !== 'undefined' ? propertyName : '';
Expand Down Expand Up @@ -1282,6 +1494,29 @@ AsposeCells.prototype.chartToImage = function(fileName,saveFormat,worksheetName,
});
};

AsposeCells.prototype.getAutoshapeByIndex = function(fileName,worksheetName,autoshapeIndex,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
worksheetName = typeof worksheetName !== 'undefined' ? worksheetName : '';
autoshapeIndex = typeof autoshapeIndex !== 'undefined' ? autoshapeIndex : 0;

if(fileName === '' || worksheetName === ''){
throw new Error('missing required params.');
}

var strURI = this.baseURI + 'cells/' + fileName + '/worksheets/' + worksheetName + '/autoshapes/' + hyperlinkIndex;
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommand('GET',signedURI,'',function(data){
if(typeof callback === 'function'){
if(data.Status === 'OK'){
callback.call(null,data);
} else {
throw new Error(data.Message);
}
}
});
};

AsposeCells.prototype.autoshapeToImage = function(fileName,saveFormat,worksheetName,autoshapeIndex,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
saveFormat = typeof saveFormat !== 'undefined' ? saveFormat : '';
Expand Down Expand Up @@ -1415,5 +1650,28 @@ AsposeCells.prototype.convert = function(fileName,saveFormat,callback){
});
};

AsposeCells.prototype.saveAs = function(fileName,options,callback){
fileName = typeof fileName !== 'undefined' ? fileName : '';
options = typeof options !== 'undefined' ? options : '';

if(fileName === ''){
throw new Error('Filename not defined.');
}

if(options === ''){
throw new Error('options missing.');
}


var strURI = this.baseURI + 'cells/' + fileName + '/saveAs';
var signedURI = Utils.Sign(strURI,this.appSID,this.appKey);

Utils.ProcessCommandContent('POST',signedURI,options,function(data){
if(typeof callback === 'function'){
callback.call(null,data);
}
});
};


module.exports = AsposeCells;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asposecloud",
"version": "1.8.0",
"version": "1.9.0",
"description": "Aspose Cloud SDK for NodeJS",
"main": "lib/aspose-cloud.js",
"scripts": {
Expand Down

0 comments on commit 7dd23dd

Please sign in to comment.