使用Phpexcel和PhpSpreadSheet时,我的excel模板中的数据验证丢失了

时间:2019-04-25 01:51:08

标签: php phpexcel xlsx phpspreadsheet

我在PhpExcel和PhpSpreadsheet中有问题。

问题是:当我在模板excel中加载带有数据验证的excel(xlsx),并且加载并修改了数据验证后,

require('../excel/vendor/autoload.php');



use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Reader\Csv;

use PhpOffice\PhpSpreadsheet\Reader\Xlsx;

use PhpOffice\PhpSpreadsheet\Reader\Xls;

$location = '../tes/tes.xlsx';

$spreadsheet = PhpOffice\PhpSpreadsheet\IOFactory::load($location);

$objPHPExcel->createSheet();

$objPHPExcel->setActiveSheetIndex(3);

$objPHPExcel->getActiveSheet()->setCellValue('A1', 'Error !!!');

$objPHPExcel->getActiveSheet()->setTitle('Error Log');  

$writer = PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, "Xlsx");

$writer->save("../tes/after_tes.xlsx");

我使用Phpexcel并尝试phpSpreadSheet,但结果相同,数据浮动仍然消失了:(

0 个答案:

没有答案