2013-04-04 65 views
0

我有網格,獲取數據從數據庫這樣的: -轉換數據從數據庫中脫穎而出

 <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"><a href="index.php?body=edit_vip&id=<?=$objResult["vip_id"];?>" original-title="Edit and View VIP Information"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/edit.png"></a></td> 
     <td width="16"><a href="#" onClick="delete_vip('<?=$objResult["vip_id"];?>');" original-title="Delete VIP"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/delete.png"></a></td> 
     <td width="16"><a href="print_single_bills_vip.php?id=<?=$objResult["vip_id"];?>" target="_new"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/print.png"></a></td> 
     <td width="16"><a href="#" onClick="vip_to_egypt('<?=$objResult["vip_id"];?>');"><img width="15" height="15" class="tabpimpa" alt="picture" src="images/sms.png"></a></td> 
     </tr> 

<? ++$i; } ?> 
</tbody></table> 

該網格將獲得來自數據庫的數據,我想導出這個結果數據到Excel。

我該怎麼做?

回答

0

嘗試使用phpexcel

編碼快樂:)

編輯:「phpexcel」對於PHP編程語言,它允許您編寫,並從不同的讀取電子表格提供了一組類項目文件格式,如Excel(BIFF).xls,Excel 2007(OfficeOpenXML).xlsx,CSV,Libre/OpenOffice Calc .ods,Gnumeric,PDF,HTML,...此項目是圍繞微軟的OpenXML標準和PHP構建的。

-by phpexcel網站

+0

你能詳細點嗎? _如何使用phpexcel? – 2013-04-04 07:17:28

+1

Stuart M:爲PHP編程語言提供一組類的項目,它允許您從不同的電子表格文件格式(如Excel(BIFF).xls,Excel 2007(OfficeOpenXML).xlsx,CSV,Libre/OpenOffice Calc .ods,Gnumeric,PDF,HTML,...這個項目是圍繞微軟的OpenXML標準和PHP構建的。 -by phpexcel site – dreamweiver 2013-04-04 07:23:09

+0

很酷,我只是回顧這個答案,因爲它被標記爲太短的審查。通過編輯它,您的評論將非常適合添加到答案本身! – 2013-04-04 07:24:18

0

http://support.microsoft.com/kb/165499以下,你應該能夠只保存HTML表格,並打開它在Excel中!

它當然會放棄大部分的格式和功能,但大多數情況下,將數據導出到excel時並不是真正的問題。

0

試試this link的解決方案。但是,如果我在哪裏,不要把它轉換成excel,如果你想打印它。您可以使用pdf,如thisthis