How to read and write Excel files in PHP

LibXL can be used in PHP with using a third party plug-in. See the instructions here.

Writing a simple Excel file

<?php
$useXlsxFormat = true;
$xlBook = new \ExcelBook('<LICENSE_NAME>', '<LICENSE_KEY>', $useXlsxFormat);
$xlBook->setLocale('UTF-8');
$xlSheet = $xlBook->addSheet('Sheet1');
$xlSheet->write(3, 3, 'Hello world!');
$xlBook->save('test.xlsx');
?>

Reading an Excel file

<?php
$useXlsxFormat = true;
$xlBook = new \ExcelBook('<LICENSE_NAME>', '<LICENSE_KEY>', $useXlsxFormat);
$xlBook->setLocale('UTF-8');
$xlBook->loadFile('test.xlsx');
$xlSheet = $xlBook->getSheet(0);
$str = $xlSheet->read(3, 3);
echo $str;
?>
Home  Setup  Download now  Purchase now