Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display progress bar while generating Excel file in php

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.

This is what I am looking to accomplish: enter image description here

EDIT:

My code is:

HTML form:

<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>

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);
    }

And in F1_export and F2_export are the functions, which generates the excel files.

like image 581
Mastor Avatar asked Nov 01 '22 01:11

Mastor


1 Answers

Use this library to upload your file, you can also show progress bar for your uploads: http://blueimp.github.io/jQuery-File-Upload/

To show progress for long-running PHP scripts: http://www.htmlgoodies.com/beyond/php/show-progress-report-for-long-running-php-scripts.html

like image 97
Raja Amer Khan Avatar answered Nov 15 '22 06:11

Raja Amer Khan