|
 |
|
รบกวนดูโค้ดออกรายงาน PDF ให้หน่อยครับ มีปัญหาเกี่ยวกับ Multicell ครับผม |
|
 |
|
|
 |
 |
|
ช่วยดูโค้ดออกรายงาน pdf ให้หน่อยครับ
ปัญหาคือ 1.คอลัมน์สุดท้ายผมใช้ Multicell เพราะข้อมูลมีเยอะต้องการให้ปัดบรรทัดแต่ทำไม background ถึงไม่สลับสีแบบตามคอลัมน์อื่นๆ
2. คอลัมน์สุดท้ายเวลาพิมตัดบรรทัดกันเยอะๆคอลัมอื่นเส้นที่ขีดกั้นไว้ไม่ยอมตามลงมา ไม่ทราบว่าต้องเขียนโค้ดยังไงครับ
รบกวนช่วยดูให้หน่อยนะครับ งานผมรีบมากยังไม่มีเวลาศึกษาเพียงพอ ขอบคุณครับ
Code (PHP)
<?php
require('fpdf.php');
class PDF extends FPDF
{
//Load data
function LoadData($file)
{
//Read file lines
$lines=file($file);
$data=array();
foreach($lines as $line)
$data[]=explode(';',chop($line));
return $data;
}
//Colored table
function FancyTable($header,$data)
{
//Colors, line width and bold font
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Header
$w=array(10,30,25,25,25,25,50);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
$this->Ln();
//Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
//Data
$fill=false;
foreach($data as $row)
{
$this->Cell($w[0],6,$row[0],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row[1],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row[2],'LR',0,'L',$fill);
$this->Cell($w[3],6,$row[3],'LR',0,'C',$fill);
$this->Cell($w[4],6,$row[4],'LR',0,'C',$fill);
$this->Cell($w[5],6,long2ip($row[5]),'LR',0,'C',$fill);
$this->MultiCell($w[6],6,$row[6],'LR',0,'L',$fill);
$this->Ln(0.1);
$fill=!$fill;
}
$this->Cell(array_sum($w),0,'','T');
}
}
$pdf=new PDF();
//Column titles
$header=array('ON','Username','Date','Time-in','Time-out','IP Address','Description');
//Data loading
//*** Load MySQL Data ***//
include ("../connect.php");
$strSQL = "SELECT * FROM logfile";
$objQuery = mysql_query($strSQL);
$resultData = array();
for ($i=0;$i<mysql_num_rows($objQuery);$i++) {
$result = mysql_fetch_array($objQuery);
array_push($resultData,$result);
}
//************************//
$pdf->SetFont('Arial','',10);
$pdf->AddPage();
//$pdf->Image('logo.png',80,8,33);
$pdf->Ln(0);
$pdf->FancyTable($header,$resultData);
$pdf->Output();
$pdf->Output("MyReport/test.pdf","F");
?>

Tag : PHP, Report Others

|
|
 |
 |
 |
 |
Date :
2010-09-14 02:37:17 |
By :
golfdukdik |
View :
1616 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีคนตอบเลยง่าา 
|
 |
 |
 |
 |
Date :
2010-09-14 15:20:02 |
By :
golfdukdik |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|