0
votes

In excel I have cells that contains formatted text (bold, color, italic). How can I get these values exactly as they are in excel with PHPExcel?

I tried with: getFormattedValue() but it just returns the normal value, without formatting.

The desired output should be in html format.

1

1 Answers

2
votes

Unless you're talking about Rich Text Objects, then bold/colour/italic etc aren't a property of the cell content, but of the cell itself.... the only style feature that is applied when calling getFormattedValue() is the number format mask for the cell (that actually changes the cell content itself).... ie the style feature that would change a numeric value like 12345.678 to a string like $ 12,345.68, or 42310 to a string like 02-Nov-2015.

It's not certain quite what you'd expect getFormattedValue() to return in terms of other formatting styles such as bold/colour/italic.... text strings don't have any inherent concept of bold, or red, or underlined, they're just text.

If you want html markup, there is no native PHP function that will do this, though you can take a look at how the HTML Writer renders style (clue: styles are set for a <td> cell, not for the text content inside that cell). So if you want html markup with style settings, then you'd need to read the cell style and write a little helper function to generate the markup from that.