问题
I have made some changes on a file using PHP and realized nothing was changes after running the code (with no any errors).
I understood that I have to save the file right after I change stuff in it.
When using the 'save' function, I get:
( ! ) Fatal error: Call to undefined method PHPExcel_Worksheet::save() in C:\wamp\www\PHPExcel\excel_fun.php on line 32
this is my function and the way I am calling it:
function save_file(){
global $objPHPExcel;
$objPHPExcel->getActiveSheet()->save('keywords.xlsx');
}
save_file();
I tried using
$objPHPExcel->save('keywords.xlsx');
too without any success
get the same error:
( ! ) Fatal error: Call to undefined method PHPExcel::save() in C:\wamp\www\PHPExcel\excel_fun.php on line 32
so what is the right way to do it?
回答1:
It's pretty straightforward to save the file, most of the examples do it.
You don't save the individual worksheet (you don't save individual worksheets in MS Excel either), you save the whole spreadsheet (PHPExcel object):
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('keywords.xlsx');
来源:https://stackoverflow.com/questions/32317742/phpexcel-how-to-save-the-loaded-file-after-changes-has-made-on-it