XLS->HTML with page breaks

Topics: Developer Forum, User Forum
Sep 13, 2010 at 10:52 AM

Hello,

I'm trying to convert plentifully formated Excel97 file into PDF. Couldn't get the desired result with the direct PDF writer, but managed to obtain good ones with HTML writer. The only problem that I have now is to generate A4 page breaks in the HTML, because now all of the content is presented as one long table, which can not be converted into A4 pages in PDF. And to be more specific:  

        $htmlWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'HTML');
	$htmlWriter->setSheetIndex(3);
	$htmlWriter->setUseInlineCSS(true);
        // here I need to say something like "maintain page breaks"
        // in order to have in the HTML blocks with style="page-break-before: always"
        $htmlWriter->save('print_auto.html');


Any help will save my project...

 

 

 

 

 

 

Coordinator
Sep 13, 2010 at 1:30 PM
Edited Sep 13, 2010 at 1:32 PM

The HTML writer doesn't currently support page breaks. If this is important, you can always raise it as a work item

Sep 13, 2010 at 3:13 PM
Edited Sep 13, 2010 at 3:14 PM

I will, even though I'll have to deal with the problem some other way.

As far as I understood, XLS-HTML-PDF conversion is preferred than pure XLS-PDF because of the cell borders issue which still is not solved (correct me, if I'm wrong). So, the support of page breaks in HTML writer will be of a great help.

Coordinator
Sep 17, 2010 at 12:17 AM
nemsys wrote:

As far as I understood, XLS-HTML-PDF conversion is preferred than pure XLS-PDF because of the cell borders issue which still is not solved (correct me, if I'm wrong). So, the support of page breaks in HTML writer will be of a great help.

 That's almost right. The PDF Writer uses the HTML Writer to generate HTML first, and then converts that to PDF. However, we don't generate HTML from XLS, but from the PHPExcel object. When you read an XLS file, you're extracting data from that file to create the PHPExcel object; so technically it's XLS-$objPHPExcel for the Reader, followed by $objPHPExcel-HTML-PDF for the Writer.

The PDF Writer current supports paper size and alignment, but I'd certainly like to get it working with headers and footers, and both that and the HTML Writer working with page breaks.

Dec 6, 2010 at 10:37 AM

@nemsys

can u post some code for inserting page breaks in html writer and pdf writer object