Hi Everyone

I want to convert Excel File to PDF using PHP.
Can anyone guide me in this matter?

I have tried PHPExcel by using tcpdf,mpdf,docpdf libraries but they didn't produce good layout.

Do you have any other suggestion?

Waiting for your reply.

Recommended Answers

All 6 Replies

What was the problem with the layout? TCPDF is quite flexible and I did not have problems creating nice tables.

When I need to produce a PDF file, I use HTML2PDF. In this case it would require some extra work to read the Excel file and generate a report output in the format that you want in PDF. If you can get PHPExcel working it will probably be less work but if not, this is another way to do it.

@chrishea
Thanks for your reply.
If i use HTML2PDF,how can i handle excel file?

@broj1
Thanks for reply.
My problem is the values of cells are not aligned,and i want to use different font size for different cells.
My code generateds pdf but cells are not justified.

I have used the php-excel-reader quite successfully. I don't believe that it handles the newer formats (xlsx) so if that is required there are other tools available. You can also have a look at this.

commented: Thanks +1

By installing "Openoffice.org" on the server we can convert doc or xls file to pdf.
Steps to convert:

  1. install openoffice.org
  2. After that server has the capabilities to handle doc or xls files. Then you can able to covert the doc or xls file to pdf by command line instruction using php.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.