0

I am new to php and want to export tables from databse to excell datasheet how do i achieve this please explain in simple language as i am very new to php. Please explain this to me with suitable example. Thank You

user2789964
  • 21
  • 2
  • 3
  • See, there is already help posted, check this link : http://stackoverflow.com/questions/17131743/creating-excel-file-from-mysql-using-php – Rajiv Ranjan Sep 24 '13 at 09:37
  • 1
    Have you googled for _export mysql to excel_ ? Do you use phpMyAdmin because you can just hit _export_ there. If you want to programe regular exports or without phpMyAdmin, this is not a task for someone very new. You could also use CURL to GET the phpMyAdmin pages for export. – Daniel W. Sep 24 '13 at 09:38
  • visit site http://phpexcel.codeplex.com/ – Nanhe Kumar Sep 24 '13 at 09:46
  • Aside from generating csv or html, have you looked at any of the libraries like those listed in the answers to http://stackoverflow.com/questions/3930975/alternative-for-php-excel – Mark Baker Sep 24 '13 at 09:52
  • @DanFromGermany he is not clear if he want data from database directly or using php he want to export from client side. – Smit Saraiya Sep 02 '16 at 09:15

1 Answers1

2

You require to create new style sheet print.css and set CSS media=print

for example :

<style media="screen">
  .noPrint{ display: block; }
  .yesPrint{ display: block !important; }
</style>

<style media="print">
  .noPrint{ display: none; }
  .yesPrint{ display: block !important; }
</style>

and add class to "yesPrint" to the sections you want to print

<div class= "yesPrint">
 <table border="1">
 <tr>
 <th>Header 1</th>
 <th>Header 2</th>
 </tr>
 <tr>
 <td>row 1, cell 1</td>
 <td>row 1, cell 2</td>
 </tr>
 <tr>
 <td>row 2, cell 1</td>
 <td>row 2, cell 2</td>
 </tr>
 </table>
 </div>

Now add a button

<input TYPE="button" onClick="window.print()">

for more detatil : http://www.codeproject.com/KB/HTML/Printing_with_CSS.aspx

Or Use TableTools.It is a plug-in for the DataTables HTML table enhancer, which adds a highly customisable button toolbar to a DataTable. Key features include:

  • Copy to clipboard
  • Save table data as CSV, XLS or PDF files
  • Print view for clean printing
  • Row selection options
  • Easy use predefined buttons
  • Simple customisation of buttons
  • Well defined API for advanced control
Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110