Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

phpoffice/phpspreadsheet 2.0.0

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine
Package summary
Share
0
issues
0
licenses
Package created
8 Dec 2016
Version published
24 Jan 2024
Maintainers
3
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does phpoffice/phpspreadsheet do?

PhpSpreadsheet, powered by the PHP Office team, is a robust library written exclusively in PHP. It provides a set of classes that make reading, writing, and working with spreadsheet files (think Excel, LibreOffice Calc etc.) quite seamless. PhpSpreadsheet allows for data extraction from these files as well as data entry, all in a couple of lines of code, making it incredibly versatile and useful for numerous applications.

How do you use phpoffice/phpspreadsheet?

Using PhpSpreadsheet package is straightforward with PHP's Composer. To use PhpSpreadsheet in your project, you begin by installing it with composer via the command: composer require phpoffice/phpspreadsheet. Once installed, you can then use it to carry out various spreadsheet related tasks.

For instance, to write data to a spreadsheet, use the following code:

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

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

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

This will create a new xlsx file named hello_world.xlsx with the cell A1 containing the text Hello and cell B1 containing World !.

If you're trying to read data from an existing spreadsheet, PhpSpreadsheet provides the IOFactory class to facilitate this process. For example:

use PhpOffice\PhpSpreadsheet\IOFactory;

$spreadsheet = IOFactory::load('Sample.xlsx');
$worksheet = $spreadsheet->getActiveSheet();
$cellData = $worksheet->getCell('A1')->getValue();

echo $cellData;

In this code, we're loading a spreadsheet file by the name Sample.xlsx and retrieving the value stored in cell A1. The value is then printed to the console.

Where are the phpoffice/phpspreadsheet docs?

Detailed information on the workings, installation and other functionality of PhpSpreadsheet can be found on the official documentation page at https://phpspreadsheet.readthedocs.io. The API documentation can be found at https://phpoffice.github.io/PhpSpreadsheet, providing an overview of the classes, functions, constants, and methods employed by the PhpSpreadsheet package.