Skip to content

[IMPROVEMENT] Excel: keep phpoffice/phpspreadsheet inside the Excel component - #12269

Open
chfsx wants to merge 2 commits into
ILIAS-eLearning:trunkfrom
srsolutionsag:improvement/12/excel-phpspreadsheet-wrapping
Open

chfsx wants to merge 2 commits into
ILIAS-eLearning:trunkfrom
srsolutionsag:improvement/12/excel-phpspreadsheet-wrapping

Conversation

@chfsx

@chfsx chfsx commented Oct 23, 2026

Copy link
Copy Markdown
Member

ilExcel wraps phpoffice/phpspreadsheet, but its API let two library details through: setCell() expected the DataType::TYPE_* constants of the library for explicit cell types, and its public methods threw the exceptions of the library. DataCollection therefore imported PhpOffice\PhpSpreadsheet\Cell\DataType, and Test, Exercise, Survey and DataCollection documented PhpOffice\PhpSpreadsheet\Exception in their @throws. This PR gives Excel its own types for both. Same approach as #12266 (guzzlehttp/psr7), #12267 (pimple/pimple) and #12268 (dflydev/fig-cookies).

Excel

  • New ILIAS\Excel\CellType (string enum: STRING, NUMERIC, BOOL, FORMULA). ilExcel::setCell() accepts CellType|string|null; strings keep working (e.g. for plugins) but are deprecated.
  • New ILIAS\Excel\ExcelException extends \RuntimeException. ilExcel translates the exceptions of the library into it, keeping the original one as previous (constructor, loadFromFile(), addSheet(), setActiveSheet(), sendToClient(), writeToFile(), writeToTmpFile(), addLink(), mergeCells()). The library exception is a \RuntimeException as well, so callers catching that keep working.
  • ExcelTestTBD is active again as ExcelTest (it was deactivated in 2024 because the library was missing) and gets tests for the exception translation and for CellType::STRING.

Components

  • DataCollection (text and text selection fields) passes CellType::STRING.
  • The @throws of DataCollection, Test, Exercise and Survey name \ILIAS\Excel\ExcelException; an unused import of DataType in Test is removed.

Testing

  • Build: [OK] All static artifacts are build!
  • PHPUnit, whole suite: green except RootFolderTest, which only fails locally because of untracked files in the root folder of my checkout.
  • Code rules gate on components/ILIAS: green. php-cs-fixer on the changed files: clean.
  • On a trunk installation, in the browser: data collection with a text field and the entry "007", "Export Excel" of the table: in the downloaded file the cell holds "007" as text, the leading zeros are kept.

@kergomard for Excel, @iszmais for DataCollection, @alex40724 for Exercise, @abrahammordev @juanma1331 for Survey, @dsstrassner for Test.

If there are no objections, I will merge this before Coding Completed.

@dsstrassner

Copy link
Copy Markdown
Contributor

Hi @thojou please Look into this for Test. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants