setTextRotation not working

Topics: User Forum
Jan 9, 2013 at 10:59 AM


The setTextRotation function doesn't appear to be working for me. Am using PHPExcel version 1.7.6 on php version 5.3.8 with Excel5.

I want to alter the orientation for an entire row and have tried setting it by entire row or individual cells without success.

Using the line:


When checking the rotation value before and after the line it is being set.

Any ideas as to what I'm doing wrong?


Jan 9, 2013 at 9:32 PM

Tested using 1.7.6

$objPHPExcel = new PHPExcel();
            ->setCellValue('A1',  "Hello")
            ->setCellValue('A2',  "World");


$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save(str_replace('.php', '.xls', __FILE__));

And works happily 


Jan 11, 2013 at 9:58 AM

Thanks very much for that Mark, however obviously we're doing something wrong as it's not working.

We have multiple sheets (not that it should make any difference) and use the following:

        $workbook = new PHPExcel();
        ** create all the sheets here **
        $setup = $workbook->setActiveSheetIndex(0)->getPageSetup();
        $writer = PHPExcel_IOFactory::createWriter($workbook, 'PDF');

All the other formating (font size, font weight, column width, etc) works perfectly. So I'm guessing this is more than likely down to my lack of understanding of PHPExcel so please point out any glaring mistakes.


Jan 11, 2013 at 7:08 PM

I'll take a stab at it. Something that looks odd to me.

$setup = $workbook->setActiveSheetIndex(0)->getPageSetup();

I'm not sure, but isn't this line making a copy of the page setup. Which you make a lot of changes to but if it is a copy, you aren't actually modifying the $workbook structure.

Which means all of your setup lines do nothing as far as the PHPExcel is concerned. 

Not sure if that helps any.

- Christopher Mullins

Jan 12, 2013 at 12:22 AM

The HTML and hence the PDF output doesn't support text rotation; I don't know if CSS3 allows you to rotate text, I'll need to take a look at that; but even if it did, it might still not be an option for any of the PDF rendering libraries