Ayush Agarwal

Ayush Agarwal

  • NA
  • 58
  • 6.7k

Export Data to Excel using OpenXML in Asp.Net MVC

Oct 23 2019 4:52 AM
How do we create a Excel file using OpenXML (not its extended libraries like EPPlus or Closed XML) in Asp.Net MVC and export data to a worsheet in it from a Datatable. The call to Action is done via Ajax.
 
$("#btnGenerateReport").click(function () {
$.ajax({
type: "POST",
url: '@Url.Action("GenerateReport", "ProcessInputData")',
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (response) {
if (response.success) {
window.location = '@Url.Action("Download", "ProcessInputData")';
}
else {
$("#errorModalMessageId").html(response.responseText);
$('#errorModal').modal('show');
}
},
error: function (ex) {
var r = jQuery.parseJSON(response.responseText);
$("#errorModalMessageId").html("Message: " + r.Message + "\nStackTrace: " + r.StackTrace + "\nExceptionType: " + r.ExceptionType);
$('#errorModal').modal('show');
}
});
 

Answers (2)