Wijmo 5 [Flex Sheet]
Auto size row in flex sheet
HTML
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.20181.436/styles/wijmo.min.css">
<script src="https://cdn.grapecity.com/wijmo/5.20181.436/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.20181.436/controls/wijmo.input.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.20181.436/controls/wijmo.grid.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.20181.436/controls/wijmo.grid.filter.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.20181.436/controls/wijmo.grid.sheet.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.20181.436/interop/angular/wijmo.angular.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.20181.436/controls/wijmo.xlsx.min.js"></script>
<div ng-app="app" ng-controller="appCtrl">
<button ng-click="applyFormula()">
Apply Formula for Column D
</button>
<wj-flex-sheet control="flex" selected-sheet-index="0" initialized="init(s,e)" style="height:400px;">
<wj-sheet name="Country" items-source="data"></wj-sheet>
</wj-flex-sheet>
</div>
JavaScript
function getData(value) {
var countries = 'I like wijmo 5 features like Flexsheet and other wijmo stuffs,Germany,UK,Japan,Italy,Greece'.split(','),
data = [];
for (var i = 0; i < value; i++) {
data.push({
id: i,
country: countries[i%countries.length],
sales: Math.random() * 1000,
expenses: Math.random() * 10000,
downloads: Math.random() * 100
});
}
return data;
}
var app = angular.module('app', ['wj']);
app.controller('appCtrl', function ($scope) {
$scope.data = new wijmo.collections.CollectionView(getData(49));
$scope.init = function (s, e) {
s.columns[1].width = 200;
s.columns[1].wordWrap = true;
// s.autoSizeRow(1); for resize particular row
s.autoSizeRows(1, s.rows.length-1, false, 5);
s.setCellData(1,0,'=sum(C2:D2)');
}
$scope.applyFormula=function(){
var sheet= $scope.flex;
for(var i=1;i< sheet.rows.length;i++){
sheet.setCellData(i,4,'=C'+(i+1)+"+D"+(i+1));
}
}
});