Question

A component of a project I am working on is to import text in cells from Excel using PHPExcel as a quicker way to populate the MySQL database. How can I achieve preserving the Rich Text formatting of the Cell Contents e.g. "The Quick Brown Fox".

I am guessing it would require parsing the content-format somehow into matching HTML tags? Is there a way to achieve this in PHPExcel?

Thanks!

Was it helpful?

Solution

It's mentioned in the documentation.

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

    $objPayable = $objRichText->createTextRun('payable within thirty days after the end of the month');
    $objPayable->getFont()->setBold(true);
    $objPayable->getFont()->setItalic(true);
    $objPayable->getFont()->setColor( new PHPExcel_Style_Color( PHPExcel_Style_Color::COLOR_DARKGREEN ) );

    $objRichText->createText(', unless specified otherwise on the invoice.');

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top