我仍然坚持使用symfony2和phpexcel ..
首先,我不知道为什么我的HTML编写器不生成<thead></thead>
标签..
我不明白为什么空白列仍会显示,如此截图所示,应用了ReadFilter:
我只想加载前13列:
public function showClientAction()
{
$excel = glob(''.path.'\\'.tofile.'\\'.$file.'.{xlsx,xls,xlsm,xlsm.ink}', GLOB_BRACE);
$filterSubset = new \PHPExcel_Reader_DefaultReadFilter('A','N');
$objReader = \PHPExcel_IOFactory::createReaderForFile($excel[0]);
$objReader->setReadFilter($filterSubset);
/** Read the list of worksheet names and select the one that we want to load **/
$worksheetList = $objReader->listWorksheetNames($excel[0]);
$sheetname = $worksheetList[0];
/** Advise the Reader of which WorkSheets we want to load **/
$objReader->setLoadSheetsOnly($sheetname);
$objPHPExcel = $objReader->load($excel[0]);
$writer = \PHPExcel_IOFactory::createWriter($objPHPExcel, "HTML");
$writer->generateSheetData();
$writer->generateStyles();
return $this->render('SocietyPerfclientBundle:Default:testexcel.html.twig', array(
'excelHtml'=>$writer
));
}
我的过滤器:
class PHPExcel_Reader_DefaultReadFilter implements PHPExcel_Reader_IReadFilter {
public function __construct($fromColumn, $toColumn) {
$this->columns = array();
$toColumn++;
while ($fromColumn !== $toColumn) {
$this->columns[] = $fromColumn++;
}
}
public function readCell($column, $row, $worksheetName = '') {
// Read columns from 'A' to 'AF'
if (in_array($column, $this->columns)) {
return true;
}
return false;
}
}
我无法理解为什么这些空白栏目在这里......
ReadFilter无法使用HTML Writer ?
我不能这样做:
.column14 { display:none;!important;}
.column15 { display:none;!important;}
.column16 { display:none;!important;}
.column17 { display:none;!important;}
etc...
因为我使用jQuery插件“floatThead”来创建固定的<thead></thead>
在我看来:
var table = $('#sheet0'); // select the table of interest
var thead = $('<thead/>').prependTo(table);
// create <thead></thead>
table.find('tbody tr.row0').appendTo(thead);
// Now the table is ready to have your chosen method applied to fix the position of the thead.
$('table.sheet0').floatThead({
position: 'fixed',
index: '8',
overflow: 'auto'
});
请帮帮我..
答案 0 :(得分:0)
$this->columns[] = $fromColumn++;
什么也不做。
尝试:
for ($i = $fromColumn; $i != $toColumns ; $i++)
{
$this->columns[$i]=$i;
}