I am trying to send two values to two cells in an excel ALREADY CREATED, which has the name query.xlsx ... but it turns out that I get the following error:
Uncaught exception 'PHPExcel_Reader_Exception' with message 'Could not open consulta.xlsx for reading! File does not exist.' in C:\xampp\htdocs\importexcel\lib\PHPExcel\PHPExcel\Reader\Excel2007.php:343 Stack trace: #0 C:\xampp\htdocs\importexcel\f.php(15): PHPExcel_Reader_Excel2007->load('consulta.xlsx') #1 {main} thrown in C:\xampp\htdocs\importexcel\lib\PHPExcel\PHPExcel\Reader\Excel2007.php on line 343
my excel file is stored on my desk, and I'm using excel 2010
the code is as follows:
<?php
error_reporting(E_ALL);
set_time_limit(0);
date_default_timezone_set('Europe/London');
set_include_path(get_include_path() . PATH_SEPARATOR . 'lib/PHPExcel/');
require_once 'lib/PHPExcel/PHPExcel/IOFactory.php';
$fileType = 'Excel2007';
$fileName = 'consulta.xlsx';
// Read the file
$objReader = PHPExcel_IOFactory::createReader($fileType);
$objPHPExcel = $objReader->load($fileName);
// Change the file
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'Hello')
->setCellValue('B1', 'World!');
// Write the file
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
$objWriter->save($fileName);
?>