Repository navigation
Report
Viames Marino edited this page Oct 19, 2026
·
2 revisions
Pair\Services\Report is an abstract base for spreadsheet exports (PhpSpreadsheet).
XLSX generation requires the optional phpoffice/phpspreadsheet package, which is not installed by Pair itself:
composer require phpoffice/phpspreadsheetSaving a .csv file uses Pair's CSV writer directly. The CSV builder can optionally use the external csv2xlsx executable for XLSX conversion, with PhpSpreadsheet as the fallback when the executable is unavailable.
save(string $filePath): booldownload(): void-
setTitle(string $title): self,setSubject(string $subject): self setBuilder(string $library): selfgetSpreadsheet(): Spreadsheet
Protected helpers for subclasses:
addColumn(string $head, ?string $format = null): selfaddRow(array $indexedCellsValue): voidsetDataAndColumnsFromDictionary(array $dictionary): selfsetDataAndColumnsFromObjects(array $objectList): self
final class OrdersReport extends \Pair\Services\Report {
/**
* Populate the report columns and rows.
*/
public function build(array $rows): void {
$this->addColumn('Order #')
->addColumn('Customer')
->addColumn('Total');
foreach ($rows as $row) {
$this->addRow([$row['id'], $row['customer'], $row['total']]);
}
}
}
$report = new OrdersReport();
$report->setTitle('Orders')->build($data);
$report->save(APPLICATION_PATH . '/temp/orders.xlsx');- Override
beforeSave()andafterSave()for custom hooks. - Date/boolean format helpers are available in the base class.
Maintained by Viames Marino — VM Ingegneria · Professional enquiries
Home · Setup · Configuration
Build with Pair 4
- Generator
- Controllers and responses
- Read models
- ActiveRecord and queries
- Forms and validation
- PairUI.js and HTML fragments
APIs and authentication
- API guide and CRUD
- Middleware and rate limits
- Users, sessions, and ACL
- Passkeys and social login
- Native mobile setup
Integrate and operate
- Integrations
- Runtime extensions and adapter keys
- Cache and cache stores
- Logs and observability
- PWA and push
- Packages and distribution
- Upgrade to v4