2017-06-06 101 views
1

我有一個excel文件,其中包含一行過濾器。自動過濾器PHPExcel

我我的Excel文件轉換爲HTML表這樣的:

 $excel = glob(''.$path'.{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); 
    /** Load $inputFileName to a PHPExcel Object **/ 

    $objPHPExcel = $objReader->load($excel[0]); 

    ### HERE I DONT KNOW WHAT TO DO ### 

    $autoFilter = $objPHPExcel->getActiveSheet()->getAutoFilter(); 
    $autoFilter->showHideRows(); 

    var_dump($autoFilter); 

    $objPHPExcel->getActiveSheet()->setAutoFilter('A1:N1'); 

    ### HELP ME PLEASE ### 

    $writer = \PHPExcel_IOFactory::createWriter($objPHPExcel, "HTML"); 
    $writer->generateStyles(); 
    $writer->generateSheetData(); 

我只是想知道如何應用和顯示我的過濾器。範圍('A1:N1')。

感謝您的幫助

回答

2

當您設置自動篩選,你需要設置範圍廣泛的數據,而不是簡單的頭;但Autofilter只提供本地Excel格式,並不適用於HTML

+0

無論如何,我不能這樣做? –

+0

不是通過PHPExcel的HTML編寫器,你必須編寫自己的 –

+0

好的,非常感謝@MarkBaker –