Developer Guide

Overview

This section covers the core capabilities of Aspose.Cells FOSS for PHP. All public classes live in the Aspose\Cells_FOSS namespace, and Workbook is the entry point for every task: create or load one, operate on its worksheets and cells, then call Save().


Core Cell Operations

Store typed values and formulas with Cell::PutValue() and the Cell->Formula property:

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

use Aspose\Cells_FOSS\Workbook;

$workbook = new Workbook();
$sheet = $workbook->Worksheets[0];
$sheet->Cells['A1']->PutValue(42500.75);
$sheet->Cells['B4']->Formula = '=SUM(B2:B3)';
$workbook->Save('core.xlsx');

XLSX Packaging

An .xlsx file is an OOXML ZIP package. Workbook::Save() writes the required parts automatically; saving is currently limited to the .xlsx format. See Working with Packaging for the lower-level package model.

Navigating Workbooks

Reach any worksheet or cell from the Workbook object graph: $workbook->Worksheets[$index] for sheets, $sheet->Cells['A1'] for cells by name. See Working with Navigation for hyperlinks.

Save-Time Validation

Before a workbook is written, WorkbookValidator checks the in-memory model for structural issues. See Working with Validation.


Tips and Best Practices

  • Cell::GetStyle() returns a copy, not a live reference: mutate the returned Style (and its Font via $style->Font), then write it back explicitly with Cell::SetStyle().
  • Saving only supports .xlsx.
  • Enable LoadOptions->TryRepairXml and TryRepairPackage before loading files of unknown quality, then check $workbook->LoadDiagnostics->HasDataLossRisk.

Common Issues

IssueCauseFix
Load fails on a questionable .xlsx fileCorrupt ZIP or malformed XMLLoad with a LoadOptions instance and set TryRepairPackage/TryRepairXml to true, then inspect LoadDiagnostics
Formula shows a stale resultAspose.Cells FOSS does not calculate formulasOpen the file in Excel/LibreOffice, which recalculates on open

FAQ

Which file formats are supported?

Only .xlsx (Excel Open XML). There is no .xls, .csv, or .ods support in this release.

Does the library evaluate formulas?

No. The Formula property stores the formula text; the value is recalculated by Excel or another spreadsheet application when the file is opened.

Is a license key required?

No. Aspose.Cells FOSS for PHP is distributed under the MIT License with no license file or key.


API Reference Summary

Class/MethodDescription
WorkbookEntry point; represents an Excel workbook
Workbook::Save($path)Writes the workbook as .xlsx
Cell::PutValue($value)Stores a typed value
Cell->FormulaFormula text stored on a cell
Cell::GetStyle() / Cell::SetStyle($style)Reads/writes cell formatting
LoadOptions->TryRepairXml / TryRepairPackageEnables repair during load
WorkbookValidator::ValidateForSave(...)Structural validation run before save

Topics

See Also