Excel 2007 cannot open php xlsxwriter generated file

343 views Asked by At

I am using xlsxwriter in php 5 under centos 7. Here is a simple script which generates an xlsx file:

<?php
require_once('xlsxwriter.class.php');
$writer = new XLSXWriter();
$writer->writeSheetRow('test', array('test'), ['border'=>'bottom']);
$writer->writeToFile('/var/www/html/test.xlsx');
?>

When I download the file, Excel 2007 warns:

Excel found unreadable content in 'test.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.

If I remove ", ['border'=>'bottom']", it opens correctly.

I tried to open it with OpenOffice (LibreOffice Calc) it works perfectly. If I save it with OpenOffice, Excel will open it correctly.

Can anybody tell me what I am doing wrong please?

0

There are 0 answers