Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert .xls to .pdf via PHP?

Tags:

php

pdf

xls

I was googling many hours but I haven't got solution yet.

I need to convert .xls file into .pdf file. How to do that? I have found this http://www.aspose.com/, but it seems, that it hasn't got PHP API, only .NET and JAVA.

Thanks for every advice...

like image 306
David Holada Avatar asked Nov 25 '25 15:11

David Holada


1 Answers

PHPExcel will do it directly (read XLS, output PDF), although the results are not very pretty.

A better solution might be to use PHPExcel to read the XLS file, render it to HTML in your code & style it the way you like it, then use an HTML->PDF converter like DOMPDF (that's the only one I've tried; there are others) to convert to PDF.

Or, if you want to skip the HTML step, render it directly to PDF using one of the PHP PDF libraries out there - my personal favourite is FPDF.

like image 94
Kryten Avatar answered Nov 27 '25 04:11

Kryten



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!