使用PHPExcel显示网格线

时间:2013-11-02 10:21:15

标签: php phpexcel

网格线没有显示.Below是我的代码。请帮助。

 <?php
 require_once '../Classes/PHPExcel.php';
 $inputFileName = 'current.xlsx'; 
 $inputFileType = PHPExcel_IOFactory::identify($inputFileName); 
 $objReader = PHPExcel_IOFactory::createReader($inputFileType);
 $objPHPExcel = $objReader->load($inputFileName);
 $objWorksheet = $objPHPExcel->getActiveSheet();
 $objPHPExcel->getActiveSheet()->setShowGridlines(true);

 $highestRow = $objWorksheet->getHighestRow(); 
 $highestColumn = $objWorksheet->getHighestColumn(); 
 $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); 

 echo '<div id="xl">' . "\n";
 echo '<table>' . "\n";
 for ($row = 1; $row <= 2; ++$row) {
 echo '<tr>' . "\n";

 for ($col = 0; $col <= $highestColumnIndex; ++$col) {
 echo '<td>' . $objWorksheet->getCellByColumnAndRow($col, $row)->getValue() . '</td>' .      "\n";
  }

 echo '</tr>' . "\n";
 }
 echo '</table>' . "\n";
echo '</div>' . "\n";
?>

1 个答案:

答案 0 :(得分:0)

我把它显示出来.Below是我的代码。

$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
$objWriter->save('php://output');
相关问题