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

auto_filter doesn't work when there are rows before table header #346

Open
hypersonic64 opened this issue Jul 10, 2023 · 1 comment
Open

Comments

@hypersonic64
Copy link

Hi,
I need a sheet with two rows followed by a table. This table has a header with filter.
This is what it should look like:
table_template
You can see the table header with filtering active in row 3.

But table filtering only works for me without the rows above the table.
As soon as I add the two rows using $writer->writeSheetRow() then the table header no longer shows filter option.
I'm using the 2023-06-02 release.

This is the code for the table only with correct set filter:
$writer = new XLSX_Writer();
$sheetName = 'TEST';
$rowFormat = ['height' => 20, 'font-size'=>10];
$formatList = ['col1'=>'string', 'col2'=>'string'];
$colOptions = ['auto_filter' => true, 'freeze_rows' => 1, 'suppress_row' => false];
$writer->writeSheetHeader($sheetName, $formatList, $colOptions);
$writer->writeSheetRow($sheetName, ['aaa', 'bbb'], $rowFormat);
$writer->writeSheetRow($sheetName, ['ccc', 'ddd'], $rowFormat);
$writer->writeToFile($file);
table

But when I try to insert the two rows above the table, then the filtering is no longer active in the table header.
As far as I know I need to write another header for inserting rows above a table, so my code looks like this:
$writer = new XLSX_Writer();
$colOptions = ['suppress_row' => true];
$writer->writeSheetHeader($sheetName, ['string'], $colOptions);
$writer->writeSheetRow($sheetName, ['HEAD'], ['height' => 30, 'font-size'=>20,'font-style'=>'bold']);
$writer->writeSheetRow($sheetName, ['SUBHEAD'], ['height' => 30, 'font-size'=>14,'font-style'=>'bold']);
$rowFormat = ['height' => 20, 'font-size'=>10];
$formatList = ['col1'=>'string', 'col2'=>'string'];
$colOptions = ['auto_filter' => true, 'freeze_rows' => 1, 'suppress_row' => false];
$writer->writeSheetHeader($sheetName, $formatList, $colOptions);
$writer->writeSheetRow($sheetName, ['aaa', 'bbb'], $rowFormat);
$writer->writeSheetRow($sheetName, ['ccc', 'ddd'], $rowFormat);
$writer->writeToFile($file);

The result is:
table_with_headline
No filtering anymore.

Any hints?
Thanks
Hyper

@hypersonic64
Copy link
Author

Anybody?

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

1 participant