我使用PhpSpreadsheet读取和写入Excel文件,我想用样式(图片,字体样式,颜色等)保存文件。
我在PhpSpreadsheet的文档中找不到方法
我可以仅使用数据而不是全部样式保存文件:
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load("myFile.xls");
// Code ...
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
$writer->save('mySavedFile.xls');
如何保存样式的文件?
答案 0 :(得分:0)
我找到了解决方案,很简单!我只是删除了它:$reader->setReadDataOnly(true);
代码:
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xls();
// $reader->setReadDataOnly(true);
$spreadsheet = $reader->load("myFile.xls");
// Code ...
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls');
$writer->save('mySavedFile.xls');