页面向phpexcel传递参数的有关问题

WBOY
Release: 2016-06-13 11:58:18
Original
1262 people have browsed it

页面向phpexcel传递参数的问题
页面上有导出excel按钮,怎么通过点击按钮,将页面的参数传到后台(前台页面不跳转)以导出对应的excel。

<input type="submit" id="excel"  value="Save as Excel"  ><br />          <br /><input type="button" id="pdf"  value="Save as PDF"  ></TD><br /><td><br /></td><br /><br /></tr><br />	</table><br />	</form><br />	<script><br /><br />	$(document).ready(function(){<br />		$("#excel").click(function(){<br />            $.ajax({<br />				type:"POST",<br />				url:'excel_GlobalNetwork.php',<br />				data:{area:$('#area').combobox('getValues').join(","),level:$('#level').combobox('getValues').join(","),bt:$('#bt').datebox('getValue'),et:$('#et').datebox('getValue')}<br />                });<br />            return false;<br />			});
Copy after login

目前我是这样做的,发现页面不跳转也没excel输出,请大师指导下,改在怎么修改代码。 
------解决方案--------------------
骚年。你的ajax只是把数据传递过去了,并没有获取任何输出的东西。怎么可能会有下载出现。
另外,下载这种东西,本身就是输出文件, 所以并不需要ajax.   a  href=excel_GlobalNetwork.php 加上传递的参数就可以了
还有。你的excel button只是下载文件,并不需要提交表单,所以只需type="button"而不是submit,否则即使是加了click事件,表单还是会提交的,这样相当于刷新了页面。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!