Question on HTML & PDF Writer with mergeCells

Topics: Developer Forum, User Forum
Apr 14, 2009 at 2:47 PM
Hello ,

I have problem using the HTML and PDF writer with merge cells.
The code below works fine in all 3 writers only when no merge involve. 
 When there are merge like below, HTML and PDF can only show the Cell 'C1'. (The Excel writer works perfectly. )

    $objPHPExcel = new PHPExcel();
    $objPHPExcel->setActiveSheetIndex(0);

    // Add some data
    $objPHPExcel->getActiveSheet()->setCellValue( 'A1'  , 'In A1');
    $objPHPExcel->getActiveSheet()->setCellValue( 'C1' , 'In C1');
    $objPHPExcel->getActiveSheet()->setCellValue( 'C2' , 'In C2 ');

    // Add merge (problem with these 2 lines... )
    $objPHPExcel->getActiveSheet()->mergeCells('A1:B2');
    $objPHPExcel->getActiveSheet()->mergeCells('C2:E5');

    // Save as Excel 5 file
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save(sprintf("%s.xls", $path));

    // Save as PDF file
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');
    $objWriter->setSheetIndex(0);
    $objWriter->save(sprintf("%s.pdf", $path ));
   
    // Save as HTML
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
    $objWriter->setSheetIndex(0);
    $objWriter->save(sprintf("%s.htm", $path ));


Developer
Apr 15, 2009 at 3:29 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.