Getting Started

Getting Started with Aspose.Cells FOSS for PHP

Welcome to Aspose.Cells FOSS for PHP, a free, MIT-licensed PHP library for reading and writing Excel XLSX workbooks. This guide takes you from a fresh clone to a saved workbook in minutes.


Prerequisites

RequirementDetail
PHP8.1 or later
Extensionszip, dom, simplexml, mbstring
OSWindows, macOS, or Linux
LicenseMIT License

Installation

git clone https://github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-PHP.git
cd Aspose.Cells-FOSS-for-PHP
composer install

Verify the setup with a minimal script:

<?php
require __DIR__ . '/autoload.php';

use Aspose\Cells_FOSS\Workbook;

$workbook = new Workbook();
echo "Aspose.Cells FOSS for PHP loaded successfully." . PHP_EOL;

See the Installation Guide for the full setup and verification steps.


What You Can Do

Once installed you can immediately:

  • Create or load workbooks via new Workbook() or new Workbook($path, $loadOptions)
  • Navigate worksheets and cells via $workbook->Worksheets, $sheet->Cells, and cell names like 'A1'
  • Store typed values and formulas with Cell::PutValue() and the Cell->Formula property
  • Format cells with Style, Font, and Color
  • Save to .xlsx with Workbook::Save()

Quick Start

Create a workbook, write typed values and a formula, apply header styling, then save it:

<?php
require __DIR__ . '/vendor/autoload.php';

use Aspose\Cells_FOSS\Color;
use Aspose\Cells_FOSS\FillPattern;
use Aspose\Cells_FOSS\Workbook;

$workbook = new Workbook();
$sheet = $workbook->Worksheets[0];

$sheet->Name = 'Products';
$sheet->Cells['A1']->PutValue('Product');
$sheet->Cells['B1']->PutValue('Price');
$sheet->Cells['A2']->PutValue('Apple');
$sheet->Cells['B2']->PutValue(2.99);
$sheet->Cells['A3']->PutValue('Orange');
$sheet->Cells['B3']->PutValue(1.99);
$sheet->Cells['B4']->Formula = '=SUM(B2:B3)';

$headerStyle = $sheet->Cells['A1']->GetStyle();
$headerStyle->Font->IsBold = true;
$headerStyle->Font->Color = Color::FromArgb(255, 255, 255, 255);
$headerStyle->Pattern = FillPattern::Solid;
$headerStyle->ForegroundColor = Color::FromArgb(255, 34, 120, 212);

$sheet->Cells['A1']->SetStyle($headerStyle);
$sheet->Cells['B1']->SetStyle($headerStyle);

$workbook->Save('products.xlsx');

Next Steps

See Also