Tim
asked on
How to set part of cell font style to Italic when using php COM to generate excel
I using php , com to generate excel file.
Now I need set some words to Italic style, like ABCD EF to ABCD EF
Code like this
$excelfile_name="test.xls" ;
$excel = new COM("excel.application") or die("Unable to instanciate excel");
$excel->Workbooks->Open("C :\template .xls");
$book=$excel->Workbooks(1) ;
$sheet=$book->worksheets(1 );
$sheet->activate;
$cell = $sheet->Cells(7,2) ;
$cell->activate;
$cell->value = 'ABCD EF';
.......(need set 'ABCD' font style to Italic)
Thanks
Now I need set some words to Italic style, like ABCD EF to ABCD EF
Code like this
$excelfile_name="test.xls"
$excel = new COM("excel.application") or die("Unable to instanciate excel");
$excel->Workbooks->Open("C
$book=$excel->Workbooks(1)
$sheet=$book->worksheets(1
$sheet->activate;
$cell = $sheet->Cells(7,2) ;
$cell->activate;
$cell->value = 'ABCD EF';
.......(need set 'ABCD' font style to Italic)
Thanks
ASKER
I test $Cell->Characters , it said "Fatal error: Call to a member function Characters() on a non-object in ".
Any help?
Any help?
since characters is an array, maybe it needs more, like
$Cell->Characters(1,1)
?
$Cell->Characters(1,1)
?
ASKER
Thanks.
I using $Cell->Characters(1,4)->fo nt->fontSt yle = "Bold";
Still get the error "Fatal error: Call to a member function Characters() on a non-object in "
Any help?
I using $Cell->Characters(1,4)->fo
Still get the error "Fatal error: Call to a member function Characters() on a non-object in "
Any help?
Is there any way in the tool you use to query what's valid? In Excel, when you type the "." after activecell, a popup box appears showing valid choices ("intellisense").
(I also sent a notifcation to other Excel experts to see if any have worked with PHP)
(I also sent a notifcation to other Excel experts to see if any have worked with PHP)
Never worked with PHP but see of this link helps you?
http://www.codeunit.co.za/2010/07/14/phpexcel-how-to-bold-a-cells-value/
Sid
http://www.codeunit.co.za/2010/07/14/phpexcel-how-to-bold-a-cells-value/
Sid
ASKER
I Think RQuadling may know how to do this.
Before he give me the answer about php COM excel issue.
I don't know how to ask him, could you help?
Thanks
Before he give me the answer about php COM excel issue.
I don't know how to ask him, could you help?
Thanks
Hi.
Just checking in ... be back in a while with what I've found.
Just checking in ... be back in a while with what I've found.
"Fatal error: Call to a member function Characters() on a non-object in" means that $Cell is incorrect.
Can you show the rest of the code?
Can you show the rest of the code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. It's working.
Thank you very much
Thank you very much
Glad to have helped.
ASKER
Hi RQuadling:
Could you check my new question.
https://www.experts-exchange.com/questions/27343581/How-to-set-cell-alignment-and-text-wrap-when-using-php-COM-to-generate-excel.html
How to set cell alignment and text wrap when using php COM to generate excel
Thanks
Could you check my new question.
https://www.experts-exchange.com/questions/27343581/How-to-set-cell-alignment-and-text-wrap-when-using-php-COM-to-generate-excel.html
How to set cell alignment and text wrap when using php COM to generate excel
Thanks
ActiveCell.Characters(Star
ActiveCell.Characters(Star
Does that help?
Maybe this?
$Cell.Characters(Start:=1,
$Cell.Characters(Start:=5,