[英]PHPExcel ReadFilter doesnt work
I'm still stuck with symfony2 and phpexcel.. 我仍然坚持使用symfony2和phpexcel。
First I don't know why my HTML writer doesn't generate <thead></thead>
tags.. 首先,我不知道为什么我的HTML编写器不生成
<thead></thead>
标记。
I don't understand why blanks columns still displaying as you can see on this screenshot, a ReadFilter is applied: 我不明白为什么空白列仍然显示,如您在此屏幕截图中所见,应用了ReadFilter:
I just want to load the first 13 columns: 我只想加载前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
));
}
My Filter : 我的筛选器:
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;
}
}
I can't understand why these blank column are here... 我不明白为什么这些空白列在这里...
ReadFilter is not working with HTML Writer ? ReadFilter无法与HTML Writer一起使用吗?
I can't just do : 我不能只是做:
.column14 { display:none;!important;}
.column15 { display:none;!important;}
.column16 { display:none;!important;}
.column17 { display:none;!important;}
etc...
Because I use jQuery Plugin "floatThead" to create a fixed <thead></thead>
因为我使用jQuery插件“ floatThead”来创建固定的
<thead></thead>
In my view : 在我看来 :
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'
});
Please help me.. 请帮我..
i think : 我认为 :
$this->columns[] = $fromColumn++;
do nothing . 没做什么 。
try : 尝试:
for ($i = $fromColumn; $i != $toColumns ; $i++)
{
$this->columns[$i]=$i;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.