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
| Requirement | Detail |
|---|---|
| PHP | 8.1 or later |
| Extensions | zip, dom, simplexml, mbstring |
| OS | Windows, macOS, or Linux |
| License | MIT License |
Installation
git clone https://github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-PHP.git
cd Aspose.Cells-FOSS-for-PHP
composer installVerify 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()ornew 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 theCell->Formulaproperty - Format cells with
Style,Font, andColor - Save to
.xlsxwithWorkbook::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
- Installation Guide: Setup and verification
- Quick Start: A longer first-workbook walkthrough
- Developer Guide: Core cell operations, packaging, navigation, and validation
- Features: Deep-dive into every feature area with PHP examples