在php中生成Excel文件时显示进度条 [英] Display progress bar while generating Excel file in php
问题描述
我有一个 HTML 表单,当您通过单击按钮提交表单时,应用程序会使用 PHPExcel 生成一个 Excel 文件.一切正常,但是当 excel 文件很大时,等待时间很长.我想添加一个进度条或显示一个百分比完成值.我的问题是我不知道如何在表单中插入它并不断更新它.
I have a HTML form that, when you submit the form by clicking a button the application generates an Excel file using PHPExcel. Everything works fine, but when the excel file is big the waiting time is quite long. I would like to add a progress bar or show a percent complete value. My problem is that I don't know how to insert that in the form and update it continuously.
这就是我想要完成的:
我的代码是:
HTML 表单:
<form action="reporteexcel.php" name = "ExportForm" method="POST">
<table>
[All different fields]
<tr>
<td style = "position:relative; top:1em;left:4em;">
<input type="submit" value="Export to excel">
<input type="button" onclick="window.close();" value = "Cancel">
</td>
</tr>
</table>
</form>
在reporteexcel.php中:
In reporteexcel.php:
include 'PHPExcel_1.8.0/Classes/PHPExcel.php';
include 'F1_Export.php';
include 'F2_Export.php';
if ($Family == "F1")
{
exportF2 ($BasicInformation, $SupplierInformation, $PhysicalParameters, $Supplier, $Family);
}
else if ($Family == "F2")
{
exportF2 ($BasicInformation, $SupplierInformation, $PhysicalParameters, $Supplier, $Family);
}
F1_export 和 F2_export 是生成excel文件的函数.
And in F1_export and F2_export are the functions, which generates the excel files.
推荐答案
使用这个库来上传你的文件,你也可以为你的上传显示进度条:http://blueimp.github.io/jQuery-File-Upload/
Use this library to upload your file, you can also show progress bar for your uploads: http://blueimp.github.io/jQuery-File-Upload/
要显示长时间运行的 PHP 脚本的进度:http://www.htmlgoodies.com/beyond/php/show-progress-report-for-long-running-php-scripts.html
To show progress for long-running PHP scripts: http://www.htmlgoodies.com/beyond/php/show-progress-report-for-long-running-php-scripts.html
这篇关于在php中生成Excel文件时显示进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!