Kali ini dengan format XML nya, kelebihannya bisa ditampilkan di web browser, tinggal mengganti ekstensinya dengan .html
kelemahannya codingnya agak sulit, dan fungsi asli excelnya tidak tercover semuanya, misal untuk membuat grafik, dsb
<startcode>
< ?php
header("Cache-Control: no-cache, no-store, must-revalidate");
header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=namaFile.xls");
//isi file excel (pakai xml)
echo '
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
</meta><meta name=ProgId content=Excel.Sheet>
</meta><meta name=Generator content="Microsoft Excel 11">
<link rel=File-List href="data.xls_files/filelist.xml">
</link><link rel=Edit-Time-Data href="data.xls_files/editdata.mso">
</link><link rel=OLE-Object-Data href="data.xls_files/oledata.mso">
<!--[if gte mso 9]><xml>
<o :DocumentProperties>
</o><o :LastAuthor>bambangriadi</o>
<o :Created>2008-06-13T04:50:40Z</o>
<o :LastSaved>2008-06-13T04:50:40Z</o>
<o :Version>11.5606</o>
</xml>< ![endif]-->
<style>
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@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;}
.xl24
{mso-style-parent:style0;
color:white;
text-align:center;
border:.5pt solid black;
background:#666699;
mso-pattern:auto none;
white-space:normal;}
.xl25
{mso-style-parent:style0;
color:white;
text-align:center;
border-top:.5pt solid black;
border-right:.5pt solid black;
border-bottom:.5pt solid black;
border-left:none;
background:#666699;
mso-pattern:auto none;
white-space:normal;}
.xl26
{mso-style-parent:style0;
border-top:none;
border-right:.5pt solid black;
border-bottom:.5pt solid black;
border-left:.5pt solid black;
background:white;
mso-pattern:auto none;
white-space:normal;}
.xl27
{mso-style-parent:style0;
border-top:none;
border-right:.5pt solid black;
border-bottom:.5pt solid black;
border-left:none;
background:white;
mso-pattern:auto none;
white-space:normal;}
.xl28
{mso-style-parent:style0;
font-size:12.0pt;
font-weight:700;
text-align:center;
white-space:normal;}
.xl29
{mso-style-parent:style0;
border-top:none;
border-right:none;
border-bottom:.5pt solid black;
border-left:none;
white-space:normal;}
-->
</style>
<!--[if gte mso 9]><xml>
<x :ExcelWorkbook>
</x><x :ExcelWorksheets>
</x><x :ExcelWorksheet>
</x><x :Name>average_01-3-2008To27-3-2008</x>
<x :WorksheetOptions>
<x :Selected/>
<x :DoNotDisplayGridlines/>
</x><x :Panes>
</x><x :Pane>
</x><x :Number>3</x>
<x :ActiveRow>25</x>
<x :ActiveCol>11</x>
<x :ProtectContents>False</x>
<x :ProtectObjects>False</x>
<x :ProtectScenarios>False</x>
<x :WindowHeight>9900</x>
<x :WindowWidth>19005</x>
<x :WindowTopX>120</x>
<x :WindowTopY>30</x>
<x :ProtectStructure>False</x>
<x :ProtectWindows>False</x>
</xml>< ![endif]-->
</link></meta></head>
<body link=blue vlink=purple>
<table x:str border=0 cellpadding=0 cellspacing=0 width=380 style="border-collapse:
collapse;table-layout:fixed;width:285pt">
<col width=55 style="mso-width-source:userset;mso-width-alt:2011;width:41pt">
</col><col width=230 style="mso-width-source:userset;mso-width-alt:8411;width:173pt">
</col><col width=43 style="mso-width-source:userset;mso-width-alt:1572;width:32pt">
</col><col width=52 style="mso-width-source:userset;mso-width-alt:1901;width:39pt">
<tr height=21 style="mso-height-source:userset;height:15.75pt">
<td colspan=4 height=21 class=xl28 width=380 style="height:15.75pt;
width:285pt">DATA PEGAWAI</td>
</tr>
<tr height=21 style="mso-height-source:userset;height:15.75pt">
<td colspan=4 height=21 class=xl28 width=380 style="height:15.75pt;
width:285pt">PT METRO KU</td>
</tr>
<tr height=17 style="height:12.75pt">
<td colspan=4 height=17 class=xl29 width=380 style="height:12.75pt;
width:285pt"> </td>
</tr>
<tr height=17 style="height:12.75pt">
<td height=17 class=xl24 width=55 style="height:12.75pt;border-top:none;
width:41pt">No</td>
<td class=xl25 width=230 style="border-top:none;width:173pt">Nama</td>
<td class=xl25 width=43 style="border-top:none;width:32pt">Umur</td>
<td class=xl25 width=52 style="border-top:none;width:39pt">Status</td>
</tr>
<tr height=17 style="height:12.75pt">
<td height=17 class=xl26 width=55 style="height:12.75pt;width:41pt"> 1</td>
<td class=xl27 width=230 style="width:173pt">Ruadi</td>
<td class=xl27 align=right width=43 style="width:32pt" x:num>23</td>
<td class=xl27 width=52 style="width:39pt">L</td>
</tr>
<tr height=17 style="height:12.75pt">
<td height=17 class=xl26 width=55 style="height:12.75pt;width:41pt"> 2</td>
<td class=xl27 width=230 style="width:173pt">Pak Min</td>
<td class=xl27 align=right width=43 style="width:32pt" x:num>14</td>
<td class=xl27 width=52 style="width:39pt">L</td>
</tr>
<tr height=17 style="height:12.75pt">
<td height=17 class=xl26 width=55 style="height:12.75pt;width:41pt"> 3</td>
<td class=xl27 width=230 style="width:173pt">Liana</td>
<td class=xl27 align=right width=43 style="width:32pt" x:num>51</td>
<td class=xl27 width=52 style="width:39pt">P</td>
</tr>
< ![if supportMisalignedColumns]>
<tr height=0 style="display:none">
<td width=55 style="width:41pt"></td>
<td width=230 style="width:173pt"></td>
<td width=43 style="width:32pt"></td>
<td width=52 style="width:39pt"></td>
</tr>
< ![endif]>
</col></table>
</body>
';
?>
</startcode>
simpan dengan nama data.xls
untuk menampilkan ke web browser simpan dengan nama data.html
gitu kan…






