Cell Formatting: Number Category

Topics: Developer Forum
Oct 29, 2009 at 1:44 AM
Edited Oct 29, 2009 at 1:45 AM

PHP 5.2.8, PHPExcel 1.7.0

G'day everyone. I'm using PHP to write accounting output to a browser.  I've been told php://output would do the trick but it doesn't seem to work.  So, doing it manually.


My main question is regarding Number category cells and alignment.  These cells are not explicitly "right" aligned, so getAlignment()->getHorizontal() doesn't deliver a right align. How can I grab the Number category?  Is there a getFormatCode() for individual cells?


It seems there should be an easy answer; I've been digging around for a few days trying to find it (and others) but no luck yet. 

Thanks ahead of time for your help!



Oct 29, 2009 at 1:52 AM

Hmm.. Not sure what you are trying to achieve. Have you played with e.g.


Perhaps try to post a specific example, then you may get better help.

Oct 29, 2009 at 2:25 AM
Edited Oct 29, 2009 at 2:33 AM

Yeah, sort of tricky without a picture...let's see:

                _______CC______                                        ________CC______

DATA        |         546.56 |              OUTPUT             | 546.56          |

IN             |           32.03 |              IN                     | 32.03            |

EXCEL:      |         341.00  |              BROWSER:         | 341.00          |

Apparently it's Excel default to right align numbers upon entry. 

The getAlignment()->getHorizontal() doesn't pick this up. Is there a method to neatly handle this right alignment?



works great. That's a big part of what I was looking for.  This one's solved, thanks!