【发布时间】:2015-06-10 15:28:38
【问题描述】:
我有一个页面,用于检索一些用 php 编写的 excel 数据...通过使用 phpexcel...这部分提供了我的公司信息
echo '<form action="final.php" method="post">';
echo "<table border='1'>";
for ($rowcount = $rowCompanyInfoStart; $rowcount <= $rowCompanyInfoEnd; $rowcount++)
{
//$data = $objWorksheet->rangeToArray('A1:' . $maxCell['column'] . $maxCell['row']);
$rangeCoordinates = $colCompanyInfoStart . $rowcount . ':' . $colCompanyInfoEnd . $rowcount;
$rowData = $sheet->rangeToArray($rangeCoordinates, NULL, TRUE, FALSE);
echo "<tr>";
$companyname=$worksheet->getCell($column.$row)->getValue();
// echo $companyname;
foreach($rowData[0] as $result)
{
echo "<td>".$result." </td>";
}
echo "</tr>";
}
echo "</table>";
echo "<br />";
echo '<input type="submit" name="sub" value="Convert into PDF" />';
// echo '<input type="text" name="resName" value="$result">';
function getdatan()
{
global $result; // declare as global
return $result;
}
echo '</form>';
这部分是我获取公司信息的地方...看起来像下面显示的表格区域...
我检索信息并能够显示为“$result”变量并使用名为“将其转换为 pdf”的提交按钮将其发送到我使用 TCPDF 的其他 php 页面 ....
通常是第二页的这部分
$pdf->SetFont('times', 'BI', 12);
// add a page
$pdf->AddPage('L', 'A4');
if(isset($_POST['submit']))
{
$result = $_GET['resName'];
$pdf->Write(20, $result, '', 0, 'C', true, 0, false, false, 0);
}
// set some text to print
$txt = <<<EOD
TCPDF Example 003
Custom page header and footer are defined by extending the TCPDF class and overriding the Header() and Footer() methods.
EOD;
// print a block of text using Write()
// $pdf->Write(20, $resultt, '', 0, 'C', true, 0, false, false, 0);
// ---------------------------------------------------------
ob_end_clean();
//Close and output PDF document
$pdf->Output('example.pdf', 'I');
但是,我无法在第二页打印“$result”...您能帮我了解如何在 pdf 上打印此表...
PS:请澄清您的帮助...
【问题讨论】: