PHPExcel:如何在对其进行更改后保存加载的文件? [英] PHPExcel: How to save the loaded file after changes has made on it?

查看:73
本文介绍了PHPExcel:如何在对其进行更改后保存加载的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 PHP 对文件进行了一些更改,但在运行代码后发现没有任何更改(没有任何错误).

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

( ! ) 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();

我尝试使用$objPHPExcel->save('keywords.xlsx'); 也没有成功

I tried using $objPHPExcel->save('keywords.xlsx'); too without any success

得到同样的错误:

( ! ) Fatal error: Call to undefined method PHPExcel::save() in C:\wamp\www\PHPExcel\excel_fun.php on line 32

( ! ) 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?

推荐答案

保存文件非常简单,大多数示例都这样做.

It's pretty straightforward to save the file, most of the examples do it.

您不保存单个工作表(您也不在 MS Excel 中保存单个工作表),而是保存整个电子表格(PHPExcel 对象):

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'); 

这篇关于PHPExcel:如何在对其进行更改后保存加载的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆