convert Data from Database to excel - php

i have grid that gets data from data base like this :-
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="gwlines">
<tbody><tr>
<th width="15">#</th>
<th width="150">Name</th>
<th width="100">Type</th>
<th width="50">Date</th>
<th width="50">From</th>
<th width="50">To</th>
<th width="30">Price</th>
<th width="30">Paid</th>
<th width="30">Remaind</th>
<th colspan="4">Actions</th>
</tr>
<?
$i=1;
while($objResult=mysql_fetch_array($objQuery)){
?>
<tr id="vip_row<?=$objResult["vip_id"];?>" <? echo ($i%2==0?'bgcolor="#edf0f6"':''); ?>>
<td><input name="cbSelect[]" type="checkbox" id="cbSelect[]" value="<?=$objResult["vip_id"]; ?>" /></td>
<td><?=$objResult["customer_name"]; ?></td>
<td><?=$objResult["vip_type"]; ?></td>
<td><?=$objResult["vip_date"]; ?></td>
<td><?=$objResult["vip_from"]; ?></td>
<td><?=$objResult["vip_to"]; ?></td>
<td><?=$objResult["vip_price"]; ?></td>
<td><?=$objResult["vip_paid"]; ?></td>
<td><?=$objResult["vip_remind"]; ?></td>
<td width="16"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/edit.png"></td>
<td width="16"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/delete.png"></td>
<td width="16"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/print.png"></td>
<td width="16"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/sms.png"></td>
</tr>
<? ++$i; } ?>
</tbody></table>
this grid will get data from data base, and i want to export this result data to excel.
how can i do this?

Following from http://support.microsoft.com/kb/165499 you should be able to just save the HTML table and open it in excel!
It will of course drop most of the formatting and the functions, but most of the time that is not a real concern when exporting data to excel.

try the solution to this link. But if I where you, don't just convert it to excel if you want to print it. You can use pdf like this and this.

try using phpexcel
happy coding :)
EDIT: "phpexcel" is a project providing a set of classes for the PHP programming language, which allow you to write to and read from different spreadsheet file formats, like Excel (BIFF) .xls, Excel 2007 (OfficeOpenXML) .xlsx, CSV, Libre/OpenOffice Calc .ods, Gnumeric, PDF, HTML, ... This project is built around Microsoft's OpenXML standard and PHP.
-by phpexcel site

Related

How can I set name to excel sheet in PHP?

Am generating .xls file with <table> tags. Export is working fine. Now I have to set the name for the sheet.
Code is as follows:
<h2>==>> Export Table into Excel file <<==</h2>
<?php
echo $excel_data = '<table border="1">
<thead>
<th width="1"></th>
<th align="left">S.No.</th>
<th align="left">Name</th>
<th align="left">DOJ</th>
</thead>
<tbody>
<tr>
<td width="1"></td>
<td align="left">1</td>
<td align="left">Sreekanth Kuriyala</td>
<td align="left">04-06-2015</td>
</tr>
<tr>
<td width="1"></td>
<td align="left">2</td>
<td>SK1</td>
<td align="left">26-07-2015</td>
</tr>
<tr>
<td width="1"></td>
<td align="left">3</td>
<td> SK2</td>
<td align="left">26-07-2015</td>
</tr>
</tbody>
</table>';
$excel_file = 'report.xls';
file_put_contents ($excel_file, $excel_data);
?>
</br>
</br>
<a href="<?php echo $excel_file; ?>" download>Export to Excel</a>
Can anyone help me on this. Thanks in advance.
For that you have to follow/generate Excel file content structure instead of table structure.
You can use PHP library for Excel file generator. There are many PHP library available you can googling it. Some of are
PHPExcel
SimpleExcel PHP
Pear Excel Writer
Excel Writer(XML) for PHP
Thanks.

Export to excel with multiple sheet using codeigniter?

I have a table which contain employee details.I have to export these employee details in excel sheet.In excel each sheet contain each employee details and sheet name should be employee name. In models I have writen a query to fetch the details from database the following is the sample view code. This following code will give only one sheet of result How I implement multiple sheet excel
<?PHP
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header ('Content-type: application/x-msexcel');
header ("Content-Disposition: attachment; filename=employee_workbook.xls" );
$this->load->view('reader/reader');
?>
<?PHP
if($result->num_rows()>0)
{
?>
<?PHP foreach($result->result_array() as $entry):?>
<table width="100%" border="1" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td width="200" bgcolor="#FFFFFF"><strong>Employee ID</strong></td>
<td width="150" bgcolor="#FFFFFF"><strong>Employee Name</strong></td>
<td width="150" bgcolor="#FFFFFF"><strong>Check in Time</strong></td>
<td width="100" bgcolor="#FFFFFF"><strong>Project Name</strong></td>
<td width="100" bgcolor="#FFFFFF"><strong>Check Out Time</strong></td>
</tr>
<tr>
<td align="left" bgcolor="#FFFFFF"><?php echo $entry['emp_id']; ?></td>
<td align="left" bgcolor="#FFFFFF"><?PHP echo $entry['emp_name']; ?></td>
<td align="left" bgcolor="#FFFFFF"><?PHP echo $entry['in_time']; ?></td>
<td align="left" bgcolor="#FFFFFF"><?PHP echo $entry['prj_name']; ?></td>
<td align="left" bgcolor="#FFFFFF"><?PHP echo $entry['out_time']; ?></td>
</tr>
</table>
<?PHP endforeach;?>
<?PHP
}
?>
You might want to look into PHPExcel, I have tried almost every script out there to export data to excel, nothing does it better than PHPExcel, you can even export to multiple sheets.
You can also use EasyXLS. Download the Excel library for PHP.
You can find a lot a code samples starting from here. You can save multiple sheets using this library.

PHP MySQL table mouse-over event to display information stored in MySQL (using Dreamweaver)

I have a database of players and their info in mysql. I have created a table in dreamweaver displaying all the players and their info. I want to display a player profile (which is stored in mysql) seperate from this table and want this information to change when the mouse is over a player in the table.
Is this possible and how do i go about it? Any help or links to tutorials will be greatly received!
I have a Screenshot of my page but am unable to post due to reputation if anyone wants to visualise my idea maybe i could send it them?
<div class="playerInfoContainer">
<table width="95%" border="0" cellpadding="3">
<caption>
Player Profile
</caption>
<tr>
<td><?php echo $row_Recordset1['PlayerProfile']; ?></td>
</tr>
</table>
</div>
</div>
<div class="squadListContainer">
<div class="DatabaseContainer">
<table width="95%" border="0" cellpadding="3">
<caption>
Bedlinog Veterans Squad
</caption>
<tr>
<th scope="col">Player Name</th>
<th scope="col">Position</th>
<th scope="col">Date of Birth</th>
<th scope="col">Points Tally</th>
<th scope="col">Man of the Matches</th>
</tr>
<?php do { ?>
<tr>
<td width="130"><?php echo $row_Recordset1['PlayerName']; ?></td>
<td width="100"><?php echo $row_Recordset1['Position']; ?></td>
<td width="100"><?php echo $row_Recordset1['DateOfBirth']; ?></td>
<td width="100"><?php echo $row_Recordset1['PointsTally']; ?></td>
<td width="100"><?php echo $row_Recordset1['MOM']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</div>
Firstly, pre-build all of the displayed mouse-over data into separate XML/JSON files. That way there's no load on a database to display 15 items at once when someone goes nuts with their cursor.
Secondly, use jquery to display a mouseover event to populate a div on the page with the separate HTML files.
As long as your jquery is correct and your css skills are up to snuff, the details will change as required and maintain the correct look/feel as it goes from one 'team/squad' to the next.

How do I export data and a base64 image to excel using PHP?

I'm trying to export the following to excel but the image is not coming through.
Example:
$today = date("d/m/y : H:i:s", time());
header ("Content-Type: application/x-msexcel");
header ("Content-Disposition: attachment; filename=\"export.xls\"" );
echo '
<table>
<tr>
<th nowrap="nowrap">Client ID</th>
<th nowrap="nowrap">Client Name</th>
<th nowrap="nowrap">No. of Staff</th>
<th nowrap="nowrap">No. of Events</th>
<th nowrap="nowrap">Fail all\'s</th>
<th nowrap="nowrap">Fail Section</th>
<th nowrap="nowrap">Fail all %</th>
</tr>
<tr>
<td nowrap="nowrap">8</td>
<td nowrap="nowrap">SEAI</td>
<td nowrap="nowrap"><div> 17 </div></td>
<td nowrap="nowrap"><div> 354 </div></td>
<td nowrap="nowrap"><div> 7 </div></td>
<td nowrap="nowrap"><div> 0 </div></td>
<td nowrap="nowrap"><div> 1.98% </div></td>
</tr>
</table>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA24AAAEsCAYAAAC7XuApAAAWw0lEQVR4nO3dT2scd57HcV/yiHKf257mT47zDPoQMAOzLJNkyBwNjcH4kmXsTMbgPmgV55SsmxmoYE1AMPgQDTQdCAi0B8HQGpCRs7HJzsB3D6Y61a1qqaXq+qm6fq8XvCFWWq1SLs6Hqq669fbgwVu/+OCzT3723qevf/fHr84efP71650vv4n/kiRJkiQlbefLb+LB51+//t0fvzr76W8+ff3O+589fHvw4K1b77z/5Pf/8Z9ffv/dqx8CAACAbnj5/Q/x64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tried the following with out success:
echo file_get_contents(base64_decode($img));
With and without the tag and with and without the file_get_contents and base64_decode.
I feel that is should be possible but I'm missing something :(. Does anyone have any ideas?
Thanks!!!
From what I see, you are trying to create an excel file (XLS) keeping headers.
Headers are not enough!
You need set of libraries. I would recommend you to do use PHPExcel
You can add images easily to it. Keep this library handy! It can do many more stuff.
Once you have installed it, you can refer to this answer for more step by step instructions.
Try complete solution using PHPExcel that I also recommend for this job.
http://phpexcel.codeplex.com/discussions/271473

php replace images with divs

below is the markup im pulling from my database table. basically i want to replace the image
<img src="http://newvision.co.ug/IM/logo_white_big.gif" width="80" style="background-color:white;padding:1px">
to
<div style='background:url(http://newvision.co.ug/IM/logo_white_big.gif) center center no-repeat;width:40px;height:40px'></div>
I dnt wanna use regular expressions just an htmlparser that ships with php
<table>
<tbody>
<tr>
<td valign="top"><a href="http://newvision.co.ug/PA/8/13/748484" target=
"_blank"><img src="http://newvision.co.ug/IM/logo_white_big.gif" width="80"
style="background-color:white;padding:1px" /></a></td>
<td valign="top">
<table>
<tbody>
<tr>
<td></td>
</tr>
<tr>
<td valign="top"><b><a target="_blank" href=
"http://newvision.co.ug/PA/8/13/748484" style="font-size:9pt">The New
Vision Online : Holland withholds sh10b over CHOGM</a></b></td>
</tr>
<tr>
<td valign="top"><a href="http://newvision.co.ug/PA/8/13/748484" style=
"font-size:8pt;color<img src="smilies/worry.gif" alt="worry" />ilver"
target="_blank">http://newvision.co.ug/PA/8/13/748484</a></td>
</tr>
<tr>
<td valign="top" style="font-size:8pt;font-weight:normal">The New Vision
is Uganda's leading daily newspaper.</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
There is no parser that ships with PHP, so use PHPQuery, a way of manipulating the DOM in a JQuery like manner instead. This will allow you to use selectors to easily swap out chunks of HTML.

Categories