Invalid character found in sheet title: getActiveSheet()->setTitle();

Topics: Developer Forum
May 30, 2012 at 12:28 PM

Hello,

if I want to set a title for a worksheet, I can't use $vars for the title?

$title = "Test Work Sheet";
$objPHPExcel->getActiveSheet()->setTitle($title);

but

$objPHPExcel->getActiveSheet()->setTitle("Test Work Sheet");

works fine.

How can I use $vars to set a worksheet title?

Thank you

 

Mark

Coordinator
May 30, 2012 at 1:21 PM
Edited May 30, 2012 at 1:22 PM

Using a variable works without problem, as long as the variable contains a valid worksheet name,

What kind of error are you getting?

May 30, 2012 at 1:30 PM

I get always:

".. Invalid character found in sheet title .."

$title = "Test Work Sheet";
$objPHPExcel->getActiveSheet()->setTitle($title);

But I think "Test Work Sheet" should be a valid worksheet name?


Thank you

 

Mark

Coordinator
May 30, 2012 at 2:28 PM

"Test Work Sheet" works for me, I can't generate a fault with the validation of sheet titles at all unless I feed it an invalid sheet name (one containing any of the characters *, :, /, \, ?, [, ] or that is more than 31 characters in length)