PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Exception

Code page $codePage not supported.

Error message

Code page $codePage not supported.

What it means

CodePage::numberToName() explicitly rejects code page 720 (DOS OEM Arabic) and 32769 with 'not supported' before attempting any mapping, because no unambiguous iconv encoding exists for them. Any string content in such a workbook is therefore unreadable by the Xls reader.

Source

Thrown at src/PhpSpreadsheet/Shared/CodePage.php:104

    {
        if (array_key_exists($codePage, self::$pageArray)) {
            $value = self::$pageArray[$codePage];
            if (is_array($value)) {
                foreach ($value as $encoding) {
                    if (@iconv('UTF-8', $encoding, ' ') !== false) {
                        self::$pageArray[$codePage] = $encoding;

                        return $encoding;
                    }
                }

                throw new PhpSpreadsheetException("Code page $codePage not implemented on this system.");
            } else {
                return $value;
            }
        }
        if ($codePage == 720 || $codePage == 32769) {
            throw new PhpSpreadsheetException("Code page $codePage not supported."); //    OEM Arabic
        }

        throw new PhpSpreadsheetException('Unknown codepage: ' . $codePage);
    }

    /** @return array<int, array<int, string>|string> */
    public static function getEncodings(): array
    {
        return self::$pageArray;
    }
}

View on GitHub (pinned to 65b080eef4)

Solutions

  1. Re-save the file from LibreOffice/Excel choosing a modern encoding (UTF-8 or Windows-1256): libreoffice --headless --convert-to xlsx file.xls
  2. If you must parse it, pre-convert the bytes yourself treating the code page as CP720 before handing the file over
  3. Keep such files out of automated pipelines by validating the code page on ingest
Defensive patterns

Strategy: try-catch

Validate before calling

// Reject/redirect unsupported legacy code pages at ingest
$fh = fopen($path, 'rb');
$head = fread($fh, 8); // OLE2 check D0 CF 11 E0 ...
fclose($fh);
if (substr(bin2hex($head), 0, 8) !== 'd0cf11e0') {
    throw new InvalidArgumentException('Not an OLE2 .xls file');
}

Try / catch

try {
    $spreadsheet = $reader->load($path);
} catch (\PhpOffice\PhpSpreadsheet\Exception $e) {
    if (str_contains($e->getMessage(), 'not supported')) {
        // CP720/32769: route file to LibreOffice conversion pipeline
    }
}

Prevention

When it happens

Trigger: Loading an .xls whose CODEPAGE record is 720 — Arabic DOS-era files, typically from old accounting or POS software — or the internal 32769 value.

Common situations: Archived Arabic-region spreadsheets from the 1990s; exports from legacy Middle-East business systems; files passed through old conversion pipelines.

Related errors


AI-assisted analysis of PHPOffice/PhpSpreadsheet@65b080eef4 (2026-08-17). Data as JSON: /api/errors/893faf5260b3a4d1. Report an issue: GitHub.