How to export to excel in Asp.Net MVC?

前端 未结 3 904
夕颜
夕颜 2021-01-13 23:07

SCRIPT

function PostExportValues(meter_id, range_type_id, start_date, end_date, returnUrl) {
    var meter = $(\"#meter_selection\").val()[0];
    $.ajax({
          


        
相关标签:
3条回答
  • 2021-01-13 23:33

    You cant call a file download on a ajax query because the browser wont trigger the file download. dont use an ajax call to your controller method, you can use like

    window.open("url/Exporttoexcel?id=");
    

    with adding paramaters.

    0 讨论(0)
  • 2021-01-13 23:41

    The problem may be that you cant actually download via an ajax call. If you look at this: jQuery plugin for requesting ajax like file downloads.

    This will help you!

    0 讨论(0)
  • 2021-01-13 23:46

    Also you can use

    window.location.href = "controllerName/GridExportToExcel?id="
    
    0 讨论(0)
提交回复
热议问题