• PHPExcel - How to simplify setting a single cell with 2 font sizes

    
    
    <?php
    require_once './Classes/PHPExcel.php';
    require_once './Classes/PHPExcel/IOFactory.php';
    
    $objPHPExcel = new PHPExcel();
    
    $phpColor = new PHPExcel_Style_Color();
    $phpColor->setRGB("0070C0");
    
    $objRichText = new PHPExcel_RichText();
    $run1 = $objRichText->createTextRun('Main Part of the Title, ');
    $run1->getFont()->applyFromArray(array( "bold" => true, "size" => 14, "name" => "Calibri", "color" => array("rgb" => "0070C0")));
    
    $run2 = $objRichText->createTextRun(' and some extra');
    $run2->getFont()->applyFromArray(array( "bold" => true, "size" => 10, "name" => "Calibri", "color" => array("rgb" => "0070C0")));
    
    $objPHPExcel->getActiveSheet()->setCellValue("A1", $objRichText);
    header ( 'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
    header ( 'Content-Disposition: attachment;filename="sq_test.xlsx"' );
    header ( 'Cache-Control: max-age=0' );
    $objWriter = PHPExcel_IOFactory::createWriter ( $objPHPExcel, 'Excel2007' );
    $objWriter->save ( 'php://output' );
    ?>
  • 0 comments:

    Post a Comment

    FAVOURITE LINE

    To steal ideas from one is plagiarism. To steal from many is Research.

    ADDRESS

    Mumbai , Maharashtra

    EMAIL

    shikha.pathak6@gmail.com
    shikha.the.swt.pari@gmail.com

    Skype

    shikha_pari