PHPSpreadSheet | Saving XLSX unhides every row

Viewed 133
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);

header("Content-Type: application/vnd.ms-excel");
header("Content-Disposition: attachment;filename=$fileName");
header("Cache-Control: max-age=0");
$writer->save('php://output');

All of the rows get un-hidden when exporting like that. I've verified that the rows are in fact hidden in the original file. How can I fix this?

1 Answers

The problem is that you make literaly a copy you must hide the row before you write the document. To hide line 10 use:

$spreadsheet->getActiveSheet()->getRowDimension('10')->setVisible(false);

More information arivable in the documentation here

Related