How to change the name of file while exporting data to Excel?

前端 未结 6 385
清歌不尽
清歌不尽 2020-12-11 03:56

How do I change the name of file while exporting data to Excel?

6条回答
  •  一向
    一向 (楼主)
    2020-12-11 04:59

    You can't do this with client-side JavaScript, you need to set the response header...

    .NET

    Response.AddHeader("Content-Disposition", "inline;filename=filename.xls")
    

    Or PHP

    $filename = 'somehting.xls';
    
    header('Content-Disposition: attachment; filename="'.$filename.'"');
    

提交回复
热议问题