Php

PHPSpreadsheet – read and write Excel from PHP

PhpSpreadsheet is a library written in pure PHP and providing a set of classes that allow you to read from and to write to different spreadsheet file formats, like Excel and LibreOffice Calc.

File formats supported

FormatReadingWriting
Open Document Format/OASIS (.ods)
Office Open XML (.xlsx) Excel 2007 and above
BIFF 8 (.xls) Excel 97 and above
BIFF 5 (.xls) Excel 95
SpreadsheetML (.xml) Excel 2003
Gnumeric
HTML
SYLK
CSV
PDF (using either the TCPDF, Dompdf or mPDF libraries, which need to be installed separately)

Software requirements

PHP version 7.1 or newer to develop using PhpSpreadsheet. Other requirements, such as PHP extensions, are enforced by composer. See the require section of the composer.json file for details.

PHP version support

Support for PHP versions will only be maintained for a period of six months beyond the end-of-life of that PHP version

Installation

Use composer to install PhpSpreadsheet into your project:

composer require phpoffice/phpspreadsheet

Hello World

This would be the simplest way to write a spreadsheet:

U<?php

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A1', 'Hello World !');

$writer = new Xlsx($spreadsheet);
$writer->save('hello world.xlsx');

URL: https://phpspreadsheet.readthedocs.io/en/latest/

Similar Posts