<!DOCTYPE html>
<html>
<head>
<script data-require="jquery@*" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link data-require="SpreadJS@*" data-semver="3.20142.13" rel="stylesheet" href="http://cdn.wijmo.com/spreadjs/jquery.wijmo.wijspread.3.20142.13.css" />
<script data-require="SpreadJS@*" data-semver="3.20142.13" src="http://cdn.wijmo.com/spreadjs/jquery.wijmo.wijspread.all.3.20142.13.js"></script>
<script src="script.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>Hello SpreadJS!</h1>
<div id="ss" style="width: 600px; height: 500px; border: 1px solid gray"></div>
</body>
</html>
// Initialize SpreadJS
$(document).ready(function() {
function POSITIONFunction() {
this.name = "POSITION";
this.maxArgs = 0;
this.minArgs = 0;
}
POSITIONFunction.prototype = new $.wijmo.wijspread.Calc.Functions.Function();
POSITIONFunction.prototype.evaluate = function(args, context) {
return context.row + "," + context.column;
};
POSITIONFunction.prototype.isContextSensitive = function(){return true;};
$("#ss").wijspread({
sheetCount: 1
}); // create wijspread control
var spread = $("#ss").wijspread("spread"); // get instance of wijspread control
var sheet = spread.getActiveSheet(); // get active worksheet of the wijspread control
// initializing the active worksheet here...
sheet.addCustomFunction(new POSITIONFunction());
sheet.setFormula(1,1,"POSITION()");
});
/* Styles go here */
Return true in isContextSensitive method of the custom function will get a context objec as the second parameter of evaluate method of Function type.
Context object contains some information about row/column position, sheet source...