user1339197
user1339197

Reputation: 21

PhpExcel error - Unreadable content when opening in Excel

I'm creating an Excel report containing UTF-8 encoded data using PHPExcel on FreeBSD. When I'm trying to open it in Excel I'm getting the following Error:

"Excel found unreadable content in '', Do you want to recover the contents of the workbook?

When I click 'yes' I get the following recovery log:

Repaired Part: /xl/styles.xml part with XML error. (Styles) Load error. Line 2, column 467. Removed Feature: Font from /xl/styles.xml part (Styles) Repaired Records: Format from /xl/styles.xml part (Styles)

and the Excel sheet is shown without bold fonts.

Any help / references would be appreciated. Thanks

Upvotes: 2

Views: 1852

Answers (1)

Les Carbonaro
Les Carbonaro

Reputation: 31

In case someone has been grappling with this, like I have for the past 2 days, and could not find any clue in this or other forums, this is what was wrong in my case.

This line was causing all the mischief:

$objPHPExcelNew->getActiveSheet()->getStyle('B4:H4')->getNumberFormat()->setFormatCode('#,#0_');

Changed it to this:

$objPHPExcelNew->getActiveSheet()->getStyle('B4:H4')->getNumberFormat()->setFormatCode('#,#0_-');

Notice the 'minus' sign missing at the very end? I didn't.

Upvotes: 3

Related Questions