0

我仍然坚持使用 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 Plugin "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'
          });

请帮我..

4

1 回答 1

0

我认为 :

$this->columns[] = $fromColumn++;

没做什么 。

尝试 :

for ($i = $fromColumn; $i != $toColumns ; $i++)
    {
        $this->columns[$i]=$i;
    }
于 2018-03-13T14:17:16.090 回答