2

I'm using the last PHPExcel version (7.7 i think). I'm able to generate my excel. I have to generate the pdf version with tcpdf, no choice here.

But the result is ugly and oversized.

enter image description here

See the gigantic font-size for 2012-000012, is 11 in excel.

As you can see, there is 2 problems here. The document is oversized, and the borders are crappy.

In order to get rid of the oversized side, i tryied this :

$this->printer->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);    

And this :

 $this->printer->getActiveSheet()->getPageSetup()->setScale(50);

The scale is set to 50, but it do not affect output. So how can i get rid of these 2 problems ?

Here is a screen, of my excel How to set auto-line break PhpExcel? .

UPDATE :

By setting cellspacing to 0 borders are handled almost as expected, still a sligth problem, maybe caused by the oversized problem.

See :

enter image description here

Is there an opion or a method call to set it to 0 ?

This lies in the writer\html.php line 915, since i don't display gridlines.

Community
  • 1
  • 1
Perello
  • 633
  • 1
  • 7
  • 22
  • I believe you're able to set specific font-settings within TCPDF. – Ben Fransen Oct 26 '12 at 14:32
  • Which of the three PDF rendering libraries have you tried – Mark Baker Oct 26 '12 at 14:32
  • And here is it: See http://www.tcpdf.org/fonts.php (SetFont, see bottom). – Ben Fransen Oct 26 '12 at 14:33
  • I have to use TCPDF. Yeah you can,set font-settings, but PHPExcel support tcpdf, so i guess he is able to specify the fonts i gave him, no ? – Perello Oct 26 '12 at 14:34
  • Nice, Ben. I'm using Courrier font, so i guess that's not the problem. Moreover, i don't access directly the tcpdf object, that's one of the nice side oh PHPExcel. – Perello Oct 26 '12 at 14:35
  • 3
    One of the reasons we dropped tcPDF from the actual PHPExcel distribution and provided configurable selection of PDF renderes was to allow the choice of better rendereing engines such as mPDF and DomPDF which produce a much cleaner PDF output – Mark Baker Oct 26 '12 at 14:55
  • 1
    And 1.7.8 is the latest version of PHPExcel, which introduced the option of choosing which rendering wngine you want to use for PDFs – Mark Baker Oct 26 '12 at 14:56
  • Ok, that's the 1.7.8 version. I must use tcpdf or a version without binary. What are the incidences of the mPDf's license GPLV2 on a commercial project ? Tcpdf is able to handle the ouput of borders, at least with raw html. So have i to create my own writer, or is it better to use tcpdf directly ? – Perello Oct 26 '12 at 15:08
  • I have a grasp, of why, tcpdf is doing shit. It works nice even with td colspan (merged cells), if border = 1 is set on the table tag, and not on tr or td tags. – Perello Oct 26 '12 at 15:18
  • But this is not compatible with PhpExcel. Since the part where you want borders, is not a table, but a part of the table. (aka the page). – Perello Oct 26 '12 at 15:26
  • Ok, i have a fix. Which handles my problem (but it may destroy something else). The problem come from a cellspacing. In PHPExcel/writer/html the function _generateTableHeader. If the cellspacing is to 0 instead of 4, tcpdf generate almost good borders (even with merged cells). Is an option or method call able to set this to 0 ? – Perello Oct 26 '12 at 15:38
  • how did you set the cellspacing? – Oriesok Vlassky Oct 09 '13 at 10:04

2 Answers2

3

To remove the borders that you find objectionable turn off grid lines on each sheet that you want to render in your the pdf.

For example: $objPHPExcel->getActiveSheet()->->setShowGridlines(false);

Ted Cohen
  • 1,017
  • 10
  • 17
2

to solve this problem I do two operations.

Step one is to set orientation for PHPexcel object

$objPHPExcel->getActiveSheet()->getPageSetup()->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);

Step two - set different paper size for PHPExcel object:

$objPHPExcel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER);

Then convert PHPExcel object to object writer

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'PDF');

$objWriter->setOrientation(PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE);

$objWriter->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A2_PAPER);

This works for me. Also i changed font size inside PHPExcel object - just like this for headers

$objPHPExcel->setActiveSheetIndex($lastsheet)->getStyle("A1:K3")->applyFromArray(
         array(
            'font'  => array(
                'size'  => 8
            )
         )
        );

and for the rest of data:

$objPHPExcel->getDefaultStyle()->getFont()->setName('Arial')->setSize(8);

Now im trying to get of ugly borders that tcPDF generates and one additional row at the end of file...