简体   繁体   中英

PHPSpreadSheet | Saving XLSX unhides every row

$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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM