Export to GitHub

php-excel - issue #9

XML entities are not encoded


Posted on Oct 28, 2008 by Massive Hippo

What steps will reproduce the problem? 1. put text containing an: ampersand, apostrophe, double-quote, less-than and/or greater-than in the data for a cell. 2. Excel will fail to read the resulting file, complaining that illegal XML characters are found.

Please provide any additional information below.

Text in cells must be XML encoded using: str_replace(''', ''', htmlspecialchars($text, ENT_QUOTES));

Comment #1

Posted on Jul 3, 2009 by Swift Horse

hi,

Any idea to modify or update the existing excel file with php?

Thanks

Comment #2

Posted on Sep 10, 2009 by Swift Horse

@gmeader: Thanks for this report. I am currently trying to address this issue in version 2:

http://code.google.com/p/php-excel/source/browse/#svn/branches/version02

However, I still need a conversion table to quickly convert special characters to the necessary representation in the used charset. This is a performance issue since larger arrays will create quite some heavy load when trying to convert every single cell.

@almightyad: Modifications will only be possible as long as the file has not been converted to the binary xls-format. It's a great idea, however. It should not be too difficult to read out the Excel-XML into an array using SimpleXML, then making changes to the structures and values and deliver the result again in an excel document. I need to think about it.

Comment #3

Posted on Sep 10, 2009 by Swift Horse

I will address this issue with a new version and/or a patch for version 1.

Comment #4

Posted on Sep 10, 2009 by Swift Horse

I've tried to fix this with version 1.1. However, I still need to test this thoroughly. Check the download section at:

http://code.google.com/p/php-excel/downloads/list

Comment #5

Posted on Sep 10, 2009 by Swift Horse

(No comment was entered for this change.)

Comment #6

Posted on Apr 29, 2010 by Happy Rhino

I'm using the following version shipped with a Drupal module to output Excel files...

// $Id: php-excel.class.php,v 1.1.2.1 2009/11/04 17:22:40 jkarsum Exp $

... and am seeing this same issue. I notice the addRow function calls htmlentities in order to generate valid XML, but am confused as to why Excel doesn't decode these properly.

Status: Started

Labels:
Type-Defect Priority-Medium Milestone-Release1.2