Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoFilter #61

Closed
damienlagae opened this issue Apr 5, 2016 · 17 comments
Closed

AutoFilter #61

damienlagae opened this issue Apr 5, 2016 · 17 comments

Comments

@damienlagae
Copy link

Hi,

Great job!
Can you add the autofilter function like PHPExcel. (https://github.com/cystbear/PHPExcel/blob/master/Tests/10autofilter.php)

@mk-j
Copy link
Owner

mk-j commented Apr 14, 2016

This is a great idea, I'll have to look into it soon.

@cgaudelet
Copy link

cgaudelet commented Nov 28, 2016

I download your class today and forked it to implement the autofilter and the FrozePane function.

the freeze_pane option take the row as first param and the columns as second
Just add the sheet_options on the writeSheet function

//autofilter and freeze pane on K1
$sheet_options = array('autofilter'=>true,'freeze_pane' =>array(1,10));
$writer = new XLSXWriter();
$writer->writeSheet($datas,'Sheet1',array(),$sheet_options);

fork_XLSXWriter.zip

@bakkerpeter
Copy link

bakkerpeter commented Feb 27, 2017

Filters do not appear; freeze pane works though. @cgaudelet what am I doing wrong?

 $excel->writeSheetHeader('Sheet1', $header, false, ['autofilter' => true, 'freeze_pane' => [1, 10]]);

test.xlsx

@cgaudelet
Copy link

cgaudelet commented Feb 27, 2017

your filter work for me on Excel 2010 :

image

@bakkerpeter
Copy link

Thanks for the quick response; funny, I'm using LibreOffice.

image

Any thoughts?

@cgaudelet
Copy link

cgaudelet commented Feb 27, 2017

the line I had just put this option on the worksheet file :

$max_cell = self::xlsCell($sheet->row_count - 1, count($sheet->columns) - 1);

	if($sheet->autofilter) {
	  $sheet->file_writer->write('<autoFilter ref="A1:'.$max_cell.'" />');
	}

If you want to make it work on libreoffice, add filter support it on your file by the hand, save it and then open the xlsx file with your zip opener :

image

and check what is on your file :

image

@bakkerpeter
Copy link

image

does not do the trick:

 if ($sheet->autofilter) {
            $sheet->file_writer->write('<autoFilter ref="A1:' . $max_cell . '"></autoFilter>');
        }

@bakkerpeter
Copy link

bakkerpeter commented Feb 27, 2017

Btw, removing these two lines prevents the following error:

            $sheet->file_writer->write('<selection pane="topRight"/>');
            $sheet->file_writer->write('<selection pane="bottomLeft"/>');
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>Resultaat herstellen naarconfig-product-rapportage-2017-02-08 00-00_2017-02-09 00-000.xml</logFileName><summary>Er zijn fouten aangetroffen in bestand /Users/gijsboddeus/Downloads/config-product-rapportage-2017-02-08 00-00_2017-02-09 00-00.xlsx</summary><removedFeatures summary="Hier volgt een lijst van verwijderde functies:"><removedFeature>Verwijderde functie: Beeld van /xl/worksheets/sheet1.xml</removedFeature></removedFeatures></recoveryLog>

@cgaudelet
Copy link

it looks like it's a libreoffice issue : https://www.mail-archive.com/[email protected]/msg395232.html

@bakkerpeter
Copy link

Aha, thanks for pointing that out!

@damienlagae
Copy link
Author

But with https://github.com/PHPOffice/PHPExcel there is not this problem.

@damienlagae
Copy link
Author

After comparing the generated files from both library, one line for OpenOffice was missing.
fix: cgaudelet/PHP_XLSXWriter#1

@Darshangohel
Copy link

@cgaudelet Can you please let me know how to freeze just first row not column?

@thomasnilsen
Copy link

thomasnilsen commented Oct 30, 2017

Any update when this feature will be accepted and available from compozer?

@damienlagae
Copy link
Author

@thomasnilsen
Copy link

@damienlagae Thanks, but then I loose my color formatting.. There is no plans to put both features in same release/repo?

@mk-j
Copy link
Owner

mk-j commented Jan 11, 2018

Auto filter and color formatting have both been added to mk-j/PHP_XLSXWriter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants