2013-11-02 76 views
1

网格线不显示。下面是我的代码。请帮助。使用PHPExcel显示网格线

<?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"; 
?> 
+0

你实际期望看到这个代码的网格线是什么? –

+0

像excel表格中的网格线 –

+0

如果你想在你自己的html标记中显示网格线,那么你必须在你自己的html标记中创建网格线 - 为PHPExcel设置ShowGridlines只影响PHPExcel作家...不是你写的任何代码在PHPExcel之外 –

回答

0

我知道它是这样显示的。下面是我的代码。

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