|
 |
|
export excel ได้แล้วแต่อยากเพิ่มตรงหัวรายงานต้องทำอย่างไรค่ะ (มีตัวอย่าง Code) |
|
 |
|
|
 |
 |
|
จาก Code สามารถออกเป็นรายงานใน excel ได้แล้วค่ะ แต่อยากได้หัวรายงานเพิ่ม ต้องเพิ่มตรงส่วนไหนค่ะ
Code (PHP)
<?
$connection=mysql_connect("localhost","root","11223344") or die("เชื่อมต่อไม่ได้");
mysql_select_db("reportloan") or die("ไม่สามารถเลือกฐานข้อมูลได้");
mysql_query("SET NAMES TIS620");
set_time_limit(0);
$q="SELECT * FROM tb_report_acc_active";
$qr=mysql_query($q);
$row_num=mysql_num_rows($qr);
echo $row_num;
$col_arr=array("AA","BB","CC","DD","EE","FF");
$col_num=count($col_arr);
echo $col_num;
echo $col_arr;
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");;
header("Content-Disposition: attachment;filename=reportdataactive.xls");
?>
<?php echo '<?xml version="1.0" encoding="windows-874"?>'; ?>
<?php echo'<?mso-application progid="Excel.Sheet"?>';?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font x:CharSet="222"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
</Styles>
<Worksheet ss:Name="รายงานความคืบหน้า">
<Table ss:ExpandedColumnCount="<?=$col_num?>" ss:ExpandedRowCount="<?=$row_num+1?>" x:FullColumns="1"
x:FullRows="1">
<Row>
<?php foreach($col_arr as $key=>$value){ ?>
<Cell><Data ss:Type="String"><?=$value?></Data></Cell>
<?php } ?>
</Row>
<?php
while($rs=mysql_fetch_array($qr)){
?>
<Row>
<Cell><Data ss:Type="String"><?=$rs['report_oldgrpcd']?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['report_acn']?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['report_cid']?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['report_title1']?></Data></Cell>
<Cell><Data ss:Type="String"><?
if($rs['report_oregno']==''){
echo "ไม่มีข้อมูล";
}else{
echo $rs['report_oregno'];
}?></Data></Cell>
<Cell><Data ss:Type="String"><?=$rs['report_bal']?></Data></Cell>
</Row>
<?php } ?>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<Selected/>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2013-10-26 11:59:58 |
By :
หนูไม่รู้ค่ะ |
View :
1685 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เงียบจังเลย
|
 |
 |
 |
 |
Date :
2013-10-27 06:42:47 |
By :
หนูไม่รู้ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวนี้ไม่ใช้ Excel แท้ ๆ ครับ ไม่ลองดู PHPExcel ล่ะครับ ทำเป็น Template ไว้ จากนั้นเพียมเพิ่มเฉพาะ Cell ที่ต้องการครับ
|
 |
 |
 |
 |
Date :
2013-10-27 07:49:33 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|