Try this it will work.
API
httpServletResponse.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
httpServletResponse.setHeader("Content-Disposition",
"attachment; filename=sample.xlsx");
workbook.write(httpServletResponse.getOutputStream());
workbook.close();
httpServletResponse.getOutputStream().close();
$http call
$scope.download = function() {
$http({
url: '/download',
method: "POST",
data: $scope.pagination,
headers: {
'Content-type': 'application/json'
},
responseType: 'arraybuffer'
}).success(function(data, status, headers, config) {
var blob = new Blob([data], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
});
saveAs(blob, "Sales_Summary_Report.xls");
}).error(function(data, status, headers, config) {
});
}
HTML
<button ng-click="download()"> Download Excel </button>