Download Excel reports based on tables in MVC

Nov 7 2019 11:51 AM
I am writing a code to pass a different data table into the view depending on a dropdown value. I have created 4 Partial Views and called them into the main controller using the if statement which uses the dropdown value to determine the code. The code seems not be working at the moment. The function is invoked on a button click and the ultimate goal is to copy the values of the datatable onto an Excel sheet. The function to invoke different partials views is given below: 
 
function fnExcelReport() {
if (SelectedValue == 1) {
<div>
@{Html.RenderAction("Report1");}
</div>
}
else if (SelectedValue == 2) {
<div>
@{Html.RenderAction("Report2");}
</div>
}
else if (SelectedValue == 3) {
<div>
@{Html.RenderAction("Report3");}
</div>
}
else if (SelectedValue == 4) {
<div>
@{Html.RenderAction("Report4");}
</div>
}
}
 

Answers (1)