<?php
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
$inputFileType = 'Excel5';
$inputFileName = './source/marks.xls'; //using this in the meantime. Will replace later with an import feature
/** Create a new Reader of the type defined in $inputFileType **/
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
/** Load $inputFileName to a PHPExcel Object **/
$objPHPExcel = $objReader->load($inputFileName);
echo '<hr />';
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($inputFileName);
$objWorksheet = $objPHPExcel->getActiveSheet();
$objPHPExcel->getActiveSheet()->getColumnDimension('A')->setVisible(false);
echo '<table>' . "\n";
foreach ($objWorksheet->getRowIterator() as $row) {
echo '<tr>' . "\n";
$cellIterator = $row->getCellIterator();
$cellIterator->setIterateOnlyExistingCells(false); // This loops all cells,
foreach ($cellIterator as $cell) {
echo '<td>' . $cell->getValue() . '</td>' . "\n";
}
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
?>
请使用此代码进行学校工作。一切顺利,除了
$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setVisible(false);
假设隐藏D列。
代码的功能是从excel文件中读取各个标记并在html视图中显示它。例如
我的目的是隐藏html视图中显示的索引号列。的&#34; removeColumn(&#39; A&#39;)&#34;工作,但我正在使用A列中的值进行搜索。所以只想隐藏该列。