PHPOffice/PhpSpreadsheet · error · PhpOffice\PhpSpreadsheet\Writer\Exception

Required floating point format not supported on this platfor

Error message

Required floating point format not supported on this platform.

What it means

The BIFF8/Xls format stores numbers as IEEE 754 64-bit doubles, and BIFFwriter::getByteOrder() self-tests this by packing 1.2345 and comparing the bytes against the known little- and big-endian encodings. If neither matches, PHP on this platform does not produce IEEE 754 doubles with pack('d', ...) and every numeric cell would be serialized corruptly, so the writer refuses to continue. On any mainstream platform (x86, x86-64, ARM, most PowerPC configurations) this check never fails.

Source

Thrown at src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php:89

    }

    /**
     * Determine the byte order and store it as class data to avoid
     * recalculating it for each call to new().
     */
    public static function getByteOrder(): int
    {
        if (!isset(self::$byteOrder)) {
            // Check if "pack" gives the required IEEE 64bit float
            $teststr = pack('d', 1.2345);
            $number = pack('C8', 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);
            if ($number == $teststr) {
                $byte_order = 0; // Little Endian
            } elseif ($number == strrev($teststr)) {
                $byte_order = 1; // Big Endian
            } else {
                // Give up. I'll fix this in a later version.
                throw new WriterException('Required floating point format not supported on this platform.');
            }
            self::$byteOrder = $byte_order;
        }

        return self::$byteOrder;
    }

    /**
     * General storage function.
     *
     * @param string $data binary data to append
     */
    protected function append(string $data): void
    {
        if (strlen($data) - 4 > $this->limit) {
            $data = $this->addContinue($data);
        }
        $this->_data .= $data;

View on GitHub (pinned to 65b080eef4)

Solutions

  1. Switch to a writer without the BIFF dependency - Xlsx or CSV - on that platform.
  2. Verify PHP float handling: var_dump(bin2hex(pack('d', 1.2345))) should be a clean little- or big-endian IEEE 754 pattern; if not, rebuild/replace the PHP build.
  3. Do not attempt to work around it in the spreadsheet data - the check is platform-wide.

Example fix

// before
(new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet))->save('out.xls');
// throws: Required floating point format not supported on this platform.

// after
try {
    (new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet))->save('out.xls');
} catch (\PhpOffice\PhpSpreadsheet\Writer\Exception $e) {
    // IEEE 754 doubles unavailable on this platform: fall back
    (new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet))->save('out.xlsx');
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    (new \PhpOffice\PhpSpreadsheet\Writer\Xls($spreadsheet))->save($path);
} catch (\PhpOffice\PhpSpreadsheet\Writer\Exception $e) {
    if (str_contains($e->getMessage(), 'floating point format')) {
        // platform cannot produce IEEE 754 doubles via pack('d') - use a non-BIFF format
        (new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet))->save(preg_replace('/\.xls$/', '.xlsx', $path));
    } else {
        throw $e;
    }
}

Prevention

When it happens

Trigger: Running the Xls writer on exotic hardware or a patched PHP whose 'd' conversion produces a non-IEEE-754 or unusual mixed-endian byte layout. Effectively unreachable on stock PHP builds for common architectures.

Common situations: Practically never seen in the wild; occasionally reported after custom/patched PHP builds or emulated environments with broken float handling. If you see it, suspect the PHP binary, not your spreadsheet.

Related errors


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