2010-12-20 80 views
-1

我們如何可以設置樣式表中,同時使用下面的代碼導出一個PHP文件到Excel導出PHP文件出類拔萃

我們可以導出一個PHP文件到Excel

header("Content-Disposition: attachment; filename=".$fname."Application.xls"); 

print "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\"> 
<style> 

@page 
    {margin:1.0in .75in 1.0in .75in; 
    mso-header-margin:.5in; 
    mso-footer-margin:.5in;} 
tr 
    {mso-height-source:auto;} 
col 
    {mso-width-source:auto;} 
br 
    {mso-data-placement:same-cell; 
    } 

.style0 
    {mso-number-format:General; 
    text-align:general; 
    vertical-align:bottom; 
    white-space:nowrap; 
    mso-rotate:0; 
    mso-background-source:auto; 
    mso-pattern:auto; 
    color:windowtext; 
    font-size:10.0pt; 
    font-weight:400; 
    font-style:normal; 
    text-decoration:none; 
    font-family:Arial; 
    mso-generic-font-family:auto; 
    mso-font-charset:0; 
    border:none; 
    mso-protection:locked visible; 
    mso-style-name:Normal; 
    mso-style-id:0;} 
td 
    {mso-style-parent:style0; 
    padding-top:1px; 
    padding-right:1px; 
    padding-left:1px; 
    mso-ignore:padding; 
    color:windowtext; 
    font-size:10.0pt; 
    font-weight:400; 
    font-style:normal; 
    text-decoration:none; 
    font-family:Arial; 
    mso-generic-font-family:auto; 
    mso-font-charset:0; 
    mso-number-format:General; 
    text-align:general; 
    vertical-align:bottom; 
    border:none; 
    mso-background-source:auto; 
    mso-pattern:auto; 
    mso-protection:locked visible; 
    white-space:nowrap; 
    mso-rotate:0;} 
.grids 
    {mso-style-parent:style0; 
    border:.5pt solid windowtext;}.head{ 
    font-weight:bold; 
} 

</style> 
<head> 
<!--[if gte mso 9]><xml> 
<x:ExcelWorkbook> 
<x:ExcelWorksheets> 
<x:ExcelWorksheet> 
<x:Name>Application List</x:Name> 
<x:WorksheetOptions> 
<x:Print> 
</x:Print> 
</x:WorksheetOptions> 
</x:ExcelWorksheet> 
</x:ExcelWorksheets> 
</x:ExcelWorkbook> 
</xml> 
<![endif]--> 
</head> 
<body>"; 

print '<table width="100%" border="0" cellspacing="1" cellpadding="2" class="tbl_content">'; 

print ' <tr class="head" valign="bottom"> 
                 <td align="center" width="7%" height="22"><b>SL No</b></td> 
                <td align="left" width="18%"><b>Name Of Party</b></td> 
                <td align="left" width="18%"><b>Godown</b></td> 
                <td align="center" width="16%" ><b>Invoice No</b></td> 
                <td align="center" width="12%"><b>Date</b></td> 
                <td align="right" width="17%"><b>Taxable Turnover</b></td> 
                <td align="right" width="14%"><b>VAT Amount</b></td> 
                <td align="right" width="8%"><b>Cess Amt.</b></td> 
                <td align="right" width="16%"><b>Total Turnover</b></td> 
               </tr>'; 

print '</table></body></html>'; 

但風格在瀏覽器中顯示時不被佔用。

+0

你用什麼庫來生成excel文件? – ZeissS 2010-12-20 11:28:55

+0

請在此問題中添加更多詳細信息。這是非常朦朧。請提供有關您正在使用的導出過程的更多信息 – 2010-12-20 11:29:04

回答