使用 PhpSpreadsheet 隐藏列
Hide Columns with PhpSpreadsheet
我试图在本地 Excel Sheet 上隐藏一些特定的列,但它没有隐藏,我使用的代码是:
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
$spreadsheet->getActiveSheet()->getColumnDimension('A')->setVisible(false);
$spreadsheet->getActiveSheet()->getColumnDimension('B')->setVisible(false);
$spreadsheet->getActiveSheet()->getColumnDimension('C')->setVisible(false);
$writer = new Xlsx($spreadsheet);
$writer->save($filePath);
为什么它不隐藏我选择的列?
我能做些什么来解决这个问题?
结合使用两者来隐藏列 'A'
$spreadsheet->getActiveSheet()->getColumnDimension('A')->setCollapsed(true);
$spreadsheet->getActiveSheet()->getColumnDimension('A')->setVisible(false);
我试图在本地 Excel Sheet 上隐藏一些特定的列,但它没有隐藏,我使用的代码是:
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filePath);
$spreadsheet->getActiveSheet()->getColumnDimension('A')->setVisible(false);
$spreadsheet->getActiveSheet()->getColumnDimension('B')->setVisible(false);
$spreadsheet->getActiveSheet()->getColumnDimension('C')->setVisible(false);
$writer = new Xlsx($spreadsheet);
$writer->save($filePath);
为什么它不隐藏我选择的列? 我能做些什么来解决这个问题?
结合使用两者来隐藏列 'A'
$spreadsheet->getActiveSheet()->getColumnDimension('A')->setCollapsed(true);
$spreadsheet->getActiveSheet()->getColumnDimension('A')->setVisible(false);