zettapi_client
Version:
Admin panel and client-side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project.
26 lines (25 loc) • 827 B
JavaScript
app.directive('zlXlsx', function ($interpolate) {
return {
restrict: 'E',
scope: {
entity: "=",
items: '='
},
transclude: true,
templateUrl: 'directives/entity/entity.xlsx.html',
controller: function ($scope, ngXlsx) {
function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
$scope.export = function () {
var data = $scope.entity.xlsx($scope.items);
var result = ngXlsx.writeXlsx(data);
var filename = $interpolate("{{ '" + $scope.entity.title + "' | translate }}")($scope) + ".xlsx";
saveAs(new Blob([s2ab(result)], { type: "application/octet-stream" }), filename);
};
}
};
});