我可以用PHPSpreadsheet读写xlsm文件吗,我是用xlsx文件做到的。
这是我的代码
<?php
require 'vendor/autoload.php';
$inputFileName = 'excels/file.xlsm';
/** Load $inputFileName to a Spreadsheet object **/
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
//get first sheet in the workbook
$inputSheet = $spreadsheet->getSheet(0);
//Edit cell D4 with number 10 on first sheet
$inputSheet->setCellValue('D4', 10);
//Save file as result.xls
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$newFileName = time();
$writer->save("excels/$newFileName.xlsm");
?>
答案 0 :(得分:0)
不,恐怕你做不到;虽然PHPSPreadsheet能够读取某些xlsm文件,但它不支持xlsm格式的读取或写入。