Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How do you create a bold cell value using PHPExcel? I know I can use to add a carriage return within the text, but is there some kind of way to bold part of cell value? I also have tried using html formatting such as <b> or <strong> but it did not work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
685 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can bold part of the text in a cell using rich text formatting, as described in section 4.6.37 of the developer documentation.

$objRichText = new PHPExcel_RichText();
$objRichText->createText('This text is ');

$objBold = $objRichText->createTextRun('bold');
$objBold->getFont()->setBold(true);

$objRichText->createText(' within the cell.');

$objPHPExcel->getActiveSheet()->getCell('A18')->setValue($objRichText);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...