php - How to open an Excel file with PHPExcel for both reading and writing? -



php - How to open an Excel file with PHPExcel for both reading and writing? -

i'm using phpexcel library, , i'm creating xls objects either writing or reading:

phpexcel_iofactory::createreaderforfile('file.xlsx') phpexcel_iofactory::createwriter('excel2007')

how can open xlsx file reading , writing?

you load file phpexcel using reader , load() method, save file using author , save() method... phpexcel unaware of source of phpexcel object... doesn't care whether have loaded file (or type of file) or created hand.

as such, there no concept of "opening read/write". read file name, , save same filename. overwrite original file changes have made in script.

edit

example

error_reporting(e_all); set_time_limit(0); date_default_timezone_set('europe/london'); set_include_path(get_include_path() . path_separator . './classes/'); include 'phpexcel/iofactory.php'; $filetype = 'excel5'; $filename = 'testfile.xls'; // read file $objreader = phpexcel_iofactory::createreader($filetype); $objphpexcel = $objreader->load($filename); // alter file $objphpexcel->setactivesheetindex(0) ->setcellvalue('a1', 'hello') ->setcellvalue('b1', 'world!'); // write file $objwriter = phpexcel_iofactory::createwriter($objphpexcel, $filetype); $objwriter->save($filename);

and can suggest read documentation, , @ sample code in /tests

php phpexcel

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -