html string in excel

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SmokyBarnable
Forum Contributor
Posts: 105
Joined: Wed Nov 01, 2006 5:44 pm

html string in excel

Post by SmokyBarnable »

I have a string that contains html and it is written to a .xls file via a excel writer class. When I open the file with excel the column that contains the html renders in the column...I know nothing about excel but I was expecting to see just the raw string. When I attempt to save the file as a text tab delimited file the html disappears. I want to retain the html. Is there a special way to encode the html string before writing it to a file? Do I need to escape the html somehow?

Thanks.
User avatar
SmokyBarnable
Forum Contributor
Posts: 105
Joined: Wed Nov 01, 2006 5:44 pm

Re: html string in excel

Post by SmokyBarnable »

I solved this problem by using htmlentities on my html string before writing it the .xls file. The html text displays properly now, and when saving it to a text file the html remains as it should. I don't really understand why it worked though. Can anyone explain it to me?

Thanks.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: html string in excel

Post by John Cartwright »

Hint: View->source
Post Reply