Skip to content

ODS export does not write font strikethrough (but works for XLSX) #4808

@xxltomcat-ux

Description

@xxltomcat-ux

Bug Description

Font strikethrough, set with $cell->getStyle()->getFont()->setStrikethrough(true);, is correctly exported for XLSX but does not appear in ODS export. Example:

$cell = $this->PhpSpreadsheet->getActiveSheet()->getCellByColumnAndRow($curFldCnt, $curRowCnt);
$cell->getStyle()->getFont()->setStrikethrough(true);

ODS output does not show strikethrough in LibreOffice or OpenOffice.

Technical Analysis

  • src/PhpSpreadsheet/Writer/Ods/Cell/Style.php method writeTextProperties does not write the style:text-line-through-style or style:text-line-through-type properties required for ODS strikethrough.
  • XLSX export includes strikethrough correctly.

Proposed Fix

Add code like this to writeTextProperties:

if ($font->getStrikethrough()) {
    $this->writer->writeAttribute('style:text-line-through-style', 'solid');
    $this->writer->writeAttribute('style:text-line-through-type', 'single');
}

Steps to Reproduce

  1. Set font strikethrough on a cell.
  2. Export as ODS.
  3. Open the file in LibreOffice/OpenOffice.
  4. Strikethrough does not appear.

Expected Behavior

Strikethrough should be exported and appear in ODS documents.

Environment

  • PhpSpreadsheet version: 2.x
  • PHP version: 8.2.30
  • LibreOffice/OpenOffice version: 26.2.0

Additional Context

This affects all ODS exports with strikethrough. See code in Writer/Ods/Cell/Style.php.


Related issue if found: N/A

Suggested Labels

  • bug
  • writer/ods
  • strikethrough (if available)

Pull Request #4812

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions