Wraptext: Is it possible in Excel5 Writer?

Topics: Developer Forum
Aug 6, 2009 at 6:47 PM

I searched for this, but I couldn't find any specific mention of this being possible in Excel5, although I did find a mention that this is possible in Excel2007.

I'm trying to set an entire column as wrapped text using Excel5, but it doesn't seem to have any effect. What's more, I'm not able to invoke the "Formatting" menu when I right-click and select Format cells. [This works on a cell on the same sheet that is not touched by the Writer...please note that I use a template which is taken from the filesystem and only the rows are populated with phpExcel.]

I'm using v28066 if I'm not mistaken, I don't want to upgrade since it will break this fix: http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=60285

But if there's no other way out and this is fixed in a later version, please let me know.

Developer
Aug 6, 2009 at 11:41 PM

>> I'm trying to set an entire column as wrapped text using Excel5, but it doesn't seem to have any effect.

This is strange? Well, PHPExcel does not yet support column styles. Maybe you can explain how you are setting the wrap text? And which program are you viewing the workbook in?

>> What's more, I'm not able to invoke the "Formatting" menu when I right-click and select Format cells.

I understand that you are using v28066, but is this also happeing with latest source code?

Aug 7, 2009 at 3:10 AM
I'm using Excel 2007 on my pc, but using the excel5 writer since
people using the older version of excel will also be using the file.
I'm using the range function to apply the wrap style for the entire
table at once. I'm setting wrap using the array method.
I'll try using the later source code and let you know if it fixes the issue.

On 8/7/09, koyama <notifications@codeplex.com> wrote:
> From: koyama
>
>>> I'm trying to set an entire column as wrapped text using Excel5, but it
>>> doesn't seem to have any effect.This is strange? Well, PHPExcel does not
>>> yet support column styles. Maybe you can explain how you are setting the
>>> wrap text? And which program are you viewing the workbook in?>> What's
>>> more, I'm not able to invoke the "Formatting" menu when I right-click and
>>> select Format cells.I understand that you are using v28066, but is this
>>> also happeing with latest source code?
>
>

--
Sent from my mobile device
Aug 10, 2009 at 7:37 AM

Hi Karpar,

As far as I know the wraptext feature works in the Excel5 writer. I don't know how you are setting it, but this is what I am doing:

$dataStyle = array('font' => array('name' => "Trebuchet MS", 'size' => 10),
        'alignment' => array('wrap' => TRUE, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_TOP)
                            );
$sharedDataStyle = new PHPExcel_Style();
$sharedDataStyle->applyFromArray($dataStyle);
// $dataRange is the range of Cells that I want to apply wrap text to.
$highestColumn = $objWorksheet->getHighestColumn();
$highestRow = $objWorksheet->getHighestRow();
$dataRange = "A4:".$highestColumn.$highestRow;

$objWorksheet->setSharedStyle($sharedDataStyle, $dataRange);

Hope this works for you.

- Ananth

Aug 10, 2009 at 4:07 PM

Hi Ananth,

Thanks for responding, I'm doing this slightly differently, but it's effectively the same. The weird part is, I also have the vertical and horizontal alignments set in the same statement (like how you have set the vertical parameter) and they seem to work. I'll post the code I'm using, hopefully it will be of more help.

Thanks again!