繁体   English   中英

单击按钮下载文件,然后将值作为参数发送到下载文件

[英]Download a file on button click and send value to the download file as parameter

假设我在索引页面上有一个表,该表在触发某些事件时会动态变化。

可以说我还有另一个文件:excel.php,它可以生成excel工作表。

我想运行excel.php文件(开始下载excel文件),并停留在我正在使用以下jquery脚本的索引页上。

$("#user_period_table_excel_btn").on("click", function(ev) {
    window.location.href = 'excel.cfm';
    ev.preventDefault();
    return false;
});

但是问题是我想在下载之前将索引页上的表htmls添加到excel.php文件中。 换句话说,我想将索引页中的值传递给excel.php文件。

我不能使用get方法,因为表非常大。

Excel.php

$tab_content=/* I want to assign the table html code on index.html page*/
/*php script for generating $tab_content to excel sheet*/

任何帮助/建议表示赞赏。

window.location.href = 'excel.php?param=123';

在excel.php的末尾仅输出excel文件内容

header("Content-Disposition: attachment; filename=\"excel.xls");
header("Content-Type: application/force-download");
readfile('excel.xls')
die();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM