Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Download table data as excel sheet using php..?

Guys i'm generating a set of data in a table after som set of calculation.. as soon as user clicks save button excel file with that data must be generated for downloading..

What is the php code for that ..

guys the data is not retrieved from database...its being displayed after a set of calculation as been performed.

Since i dont have any idea ive not posted any related code...sry for that..

below is how my table looks like

https://ibb.co/mUMOrQ

below is my table code

       <div id="myModal" class="modal fade in">
    <div class="modal-dialog">
        <div class="modal-content">

            <div class="modal-header">
                <a class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove"></span></a>
                <div class="table-title">
                <h3>CUF Table</h3>
                </div>
                <table class="table-fill" id="tabid">
                <thead>
            </div>

    <div class="modal-body">
        <tr>
        <th class="text-left">TimeStamp</th>
        <th class="text-left">CUF</th>
        </tr>
        </thead>
        <tbody class="table-hover">
        <!--tr>
        <td class="text-left" id="data"></td>
        <td class="text-left" id="data1"></td>
        </tr-->
        </tbody>
        </table>
    </div>

     <div class="modal-footer">
                <div class="btn-group">
                    <button id="change-chart"  class="btn btn-primary"><span class="glyphicon glyphicon-check"></span>Save</button>
                  </div>
      </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->   

Below is jquery that ive included to download the file

     $("#BUTTON").click(function(){
     $("#TABLE").table2excel({
     // exclude CSS class
    exclude: ".noExl",
    name: "Data",
    filename: "Data" //do not include extension
   });
   });
like image 303
Pradeep Avatar asked Oct 30 '22 07:10

Pradeep


1 Answers

You can use one of the following

https://stackoverflow.com/a/38761185/5350773

http://www.jqueryscript.net/table/Export-Html-Table-To-Excel-Spreadsheet-using-jQuery-table2excel.html

like image 86
Zedex7 Avatar answered Nov 06 '22 00:11

Zedex7