我只是需要你的帮助我的代码。我的问题是我如何才能得到表标题从上一页,并访问它在其余的网页?如果我有一个大的数据,我想也指出标题表在每一页。但我不知道如何做到这一点。
下面是构建表的函数:
function BuildTable($header,$data) {
//Colors, line width and bold font
$this->SetFillColor(255,255,255);
$this->SetTextColor(0);
$this->SetDrawColor(0,0,0);
$this->SetLineWidth(.3);
$this->SetFont('Arial','',7);
//Header
// make an array for the column widths
$this->SetFillColor(0,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(0,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
$w = array(15,120,30,30); //CHANGE THIS
// send the headers to the PDF document
for($i = 0; $i < count($header); $i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',1);
$this->Ln();
//Color and font restoration
$this->SetFillColor(255,255,230);
$this->SetTextColor(0);
$this->SetFont('');
$this->SetTextColor(0);
$fill = false; // used to alternate row color backgrounds
//HERE'S THE PART THAT LOOPS THE DATA
foreach($data as $row){
$this->Cell($w[0],4,$row[0],'LR',0,'C',$fill);
$this->SetFont('');
$this->Cell($w[1],4,$row[1],'LR',0,'L',$fill);
$this->SetFont('');
$this->Cell($w[2],4,$row[2],'LR',0,'R',$fill);
$this->SetFont('');
$this->Cell($w[3],4,$row[3],'LR',0,'R',$fill);
$this->SetFont('');
$this->Ln();
$fill =! $fill;
}
$this->Cell(array_sum($w),0,'','T');
$this->Ln(50);
$this->Ln(50);
}
下面是PDF类的调用
foreach($result->result_array() as $row){
$data[] = array($row['item_qty'],
$row['itemname'],
number_format($row['item_price'],2),
number_format($row['total'],2),
);
}
$pdf = new PDF();
$pdf->AliasNbPages();
$header = array('QTY','ITEM / DESCRIPTION' , 'UNIT PRICE', 'TOTAL AMOUNT');
$pdf->SetFont('Arial','',8);
$pdf->SetFillColor(255,0,0);
$pdf->AddPage('l');
$pdf->Ln();
$pdf = new PDF();
顺便说一句,我也有一个页眉和页脚的功能。在第一行我需要有39行,不包括表头和第二行,也应该是其余的36行。
我该怎么计算呢?我应该在哪里需要计算呢?
请帮帮我,伙计们谢谢。
1条答案
按热度按时间bq8i3lrv1#
根据fpdf教程。
reference