Good morning,
I am working with the PHPExcel library to duplicate an Excel spreadsheet. I'm only interested in its content, its format is not.
The first thing I do is open the Excel file:
$archivo = $_FILES['fichero_usuario']['tmp_name'];
$inputFileType = PHPExcel_IOFactory::identify($archivo);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($archivo);
The tab I want to duplicate is in position 1 (2nd tab of the Excel document). So, the following line that I include is:
$objPHPExcel->setActiveSheetIndexByIndex(1);
With the intention of positioning myself on the sheet that I want to duplicate. Next I try to get the content of the sheet I want to duplicate:
$sheet = $objPHPExcel->getActiveSheet();
And I try to add the new sheet in index 4, since the Excel file is composed of 4 sheets (0,1,2,3):
$archivo->addSheet($sheet,4);
But something I'm doing wrong because it shows me the following error:
Fatal error: Call to a member function addSheet () on string
The truth is that it is the first time I work with this bookstore and sometimes I can not understand its behavior.
In addition, another question arises: when I make changes to the structure of the Excel file through this library, do I have to "save" using the source code to see the changes?
Thanks in advance for your comments and help.
Greetings, Ricardo