Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Commit

Permalink
Ajax Download
Browse files Browse the repository at this point in the history
  • Loading branch information
VahidN committed May 29, 2018
1 parent b48d3fb commit 1695197
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/EPPlus.Core.SampleWebApp/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,31 @@
<input type="submit" value="Upload" />
</form>
</fieldset>

<fieldset style="margin-top: 15px">
<legend>Handling Blob Responses</legend>
<button type="button" onclick="downloadBlob()">Ajax Download</button>
</fieldset>

@section Scripts
{
<script type="text/javascript">
function downloadBlob()
{
fetch('/Home/InMemoryReport')
.then(function(response) {
return response.blob();
})
.then(function(xlsxBlob) {
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
let url = window.URL.createObjectURL(xlsxBlob);
a.href = url;
a.download = "report.xlsx";
a.click();
window.URL.revokeObjectURL(url);
});
}
</script>
}

0 comments on commit 1695197

Please sign in to comment.