Get data from one cell.

Topics: User Forum
Oct 8, 2008 at 5:44 PM
Hi Guys,

Great bit of software you've written here. I've a question but couldn't find my answer anywhere...

I'm trying to use it to read one specific cell in a spreadsheet (and maybe assign it to a string in PHP). Is this possible or is the software more designed to write spreadsheets rather than read the data?

Kind regards,

Oct 8, 2008 at 6:06 PM
This should be quite straightforward. Use 'Excel2007' if you need to read xlsx, use 'Excel5' if you need to read xls

$reader = PHPExcel_IOFactory::createReader('Excel2007');

$excel = $reader->load('test.xlsx');
$sheet = $PHPExcel->getActiveSheet();

$string = $sheet->getCell('A1')->getValue();

Oct 8, 2008 at 6:09 PM
Perfect.. Exactly what I needed..

Will the functions be processed in those cells?

Thank you again.

Oct 8, 2008 at 6:32 PM
If you want processed results, you need this instead:

$string = $sheet->getCell('A1')->getCalculatedValue();