【发布时间】:2016-05-01 10:23:15
【问题描述】:
如何更改列的长度以适合每个单元格的所有字符?
尝试使用动态长度,但没有太大帮助,
使用FPDF函数获取此表,表内容来自数据库..
创建表格的代码
function LoadData($file)
{
// Read file lines
/*$lines = file($file);
$data = array();
foreach($lines as $line)*/
while($row=mysqli_fetch_assoc($file))
$data[] =array_values($row);
return $data;
}
// Simple table
function BasicTable($header, $data)
{
// Header
foreach($header as $col)
$this->Cell(40,7,$col,1);
$this->Ln();
// Data
foreach($data as $row)
{
foreach($row as $col)
$this->Cell(40,6,$col,1);
$this->Ln();
}
//The first parameter of Cell() is the width of the cell.
}
调用sn-p
$sql="select `station`,`Category`,`Agency`,`startyear` from station";
$res=mysqli_query($conn,$sql);
$data = $pdf->LoadData($res);
$pdf->AddPage();
$pdf->BasicTable($header,$data);
【问题讨论】:
-
请向我们展示您正在使用的代码,以便在您的解决方案中建立答案。
-
@etalon11 ,我已经提供了代码
标签: php html html-table fpdf