Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

Convert Excel-spreadsheets to PDF-files
Welcome, Guest. Please login or register.
December 02, 2008, 06:37:36 AM
11304 Posts in 1248 Topics by 498 Members
Latest Member: katCheeme
Experts Round Table Network  |  Serverside Technology  |  PHP  |  Convert Excel-spreadsheets to PDF-files « previous next »
Pages: [1]
Author Topic: Convert Excel-spreadsheets to PDF-files  (Read 916 times)
NeoTeq

Offline Offline

Posts: 21


« on: February 06, 2006, 07:42:33 AM »

I've started a small project which requires me to convert reports, generated in Excel, into PDF-files. The server on which this is done runs some flavor of Linux, and it will need to be done on-the-fly from PHP.

As I get more details, I'll provide them. I'll take any suggestions on how to proceed. Thanks!
Logged

Still claiming: There is no peace.
Anonymous
Guest
« Reply #1 on: February 06, 2006, 08:13:43 AM »

I use an Excel Spreadsheet Reader class to get Excel data into PHP and I use a PDF Writer class to get PHP to create PDF files.

Somewhere in the middle is the join.

I read Excel data (statements from our suppliers for cross referencing for invoicing).

I write PDFs (fax pages with controlled headings and barcode data to log against order processing).

I don't do the two together. Yet.

Obviously, there are freeware tools to allow you to use Excel to create PDF files, but that isn't the PHP way!

How complex are the spreadsheets? Charts? External data links?
Logged
NeoTeq

Offline Offline

Posts: 21


« Reply #2 on: February 06, 2006, 08:25:38 AM »

I haven't received the examples yet, but I'm not expecting much... simple data rows, maybe some formatting for headers/etc. maybe a couple formulas, I'm not expecting charts but it's not specifically said there won't be.

Can you give me links to the classes you're using?
Logged

Still claiming: There is no peace.
Anonymous
Guest
« Reply #3 on: February 06, 2006, 08:34:37 AM »

http://www.excelparser.com/index.php

and

http://www.fpdf.org/
Logged
Anonymous
Guest
« Reply #4 on: February 06, 2006, 08:37:58 AM »

I did create a small wrapper for the excel reading class to deal with formatting strings that match dates.
Logged
NeoTeq

Offline Offline

Posts: 21


« Reply #5 on: February 06, 2006, 09:20:27 AM »

FPDF looks promising... easy to work with and free. Looks like it's not too much of a hassle to create tables either, which will be a good thing.

I've come across the excelparser before,  and although it looks alright, I'd prefer something free, and I can't seem to get the trial version to work whatsoever. Is there anything else?

Thanks for your help so far, by the way!
Logged

Still claiming: There is no peace.
Anonymous
Guest
« Reply #6 on: February 07, 2006, 01:13:28 AM »

The excel class is VERY good. It is well worth the money.

I did try the spreadsheet reader that is in sourceforge, but it wasn't good enough for what I wanted.

What problems are you having with the trial version?

I think you need to install an opcode hanlder of some sort (from memory) as the trial code is protected.
Logged
GrandSchtroumpf
Mentor

Offline Offline

Posts: 410



« Reply #7 on: February 07, 2006, 10:18:02 PM »

I would not use PHP to do the conversion...
Why not just using the PHP exec() to issue a command that converts your file?
This way you keep all the formating defined in your original file.

A quick web search and i found this article that explains how to convert a file into PDF using OpenOffice in a command line:
http://www.xml.com/pub/a/2006/01/11/from-microsoft-to-openoffice.html
This should work with all the file formats that OpenOffice supports.
Logged
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #8 on: February 08, 2006, 01:25:44 AM »

good point I agree with. I also recommend the same processus to generate the PDF. I was very disappointed by the "built-in" possibilities of PHP, and resolved to using HtmlDoc at the command-line level. It's definitely suited for generating nicely-cut, nicely-formatted PDFs from the HTML output that PHP classically generates (via ob_* of course)

See http://www.easysw.com/htmldoc/

regards
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
NeoTeq

Offline Offline

Posts: 21


« Reply #9 on: February 09, 2006, 01:05:39 PM »

Quote from: "GrandSchtroumpf"
A quick web search and i found this article that explains how to convert a file into PDF using OpenOffice in a command line:
http://www.xml.com/pub/a/2006/01/11/from-microsoft-to-openoffice.html
This should work with all the file formats that OpenOffice supports.


Interesting suggestion, and I will certainly look into it! Thanks!
Logged

Still claiming: There is no peace.
Esopo
Governing Council Member
*
Offline Offline

Posts: 74


WWW
« Reply #10 on: February 10, 2006, 01:36:31 AM »

If your Excel files are "good to go" I wouldn't use PHP either. I used to work with Adobe Acrobat and although I hated its guts the Distiller was pretty decent. I had to convert about 50 pages a day and all I did was send my files to the distiller's watch folder and then sit back and let it go.

I don't know if the distiller would automatically deal with Excel files though. I know the PDF printer did (it comes with the pack bundle). As an alternative you could setup a batch process using VBA in Excel to print the files to the default printer (the PDF printer installed).

Right now I am using Macromedia (Adobe) FlashPaper that also installs as a system printer that can save the output as either FlashPaper or PDF (and cheaper than the Acrobat suite).

And I have heard of a few free PDF makers out there although I couldn't recommend any... such as this one:
http://www.pdf995.com/

For PHP, I checked these out once and they seemed ok (and free):
- HTML_ToPDF 3.3
http://www.rustyparts.com/pdf.php

- dompdf
http://www.digitaljunkies.ca/dompdf


Hope any of these help.

UPDATE:
BTW, I just realized you need it to run on Linux. This may be the most useless post of the site then ;)
Logged
muso
Site Builder

Offline Offline

Posts: 8


WWW
« Reply #11 on: February 10, 2006, 07:05:11 AM »

Personally, I use CutePDF, which works as a printer driver.  This allows any printable document to be outputted as a PDF:

http://www.cutepdf.com/Products/CutePDF/writer.asp
Logged
NeoTeq

Offline Offline

Posts: 21


« Reply #12 on: February 11, 2006, 05:46:39 AM »

Quote from: "Esopo"
BTW, I just realized you need it to run on Linux. This may be the most useless post of the site then ;)


I was reading, and wondering myself... Had a good laugh though so it wasn't entirely useless. :D

Quote from: "muso"
Personally, I use CutePDF, which works as a printer driver. This allows any printable document to be outputted as a PDF


That leaves me with the problem of opening the Excel file on Linux. That's the toughest part all along  :(
Logged

Still claiming: There is no peace.
muso
Site Builder

Offline Offline

Posts: 8


WWW
« Reply #13 on: February 11, 2006, 11:03:24 AM »

Quote from: "NeoTeq"
Quote from: "Esopo"
BTW, I just realized you need it to run on Linux. This may be the most useless post of the site then ;)


I was reading, and wondering myself... Had a good laugh though so it wasn't entirely useless. :D

Quote from: "muso"
Personally, I use CutePDF, which works as a printer driver. This allows any printable document to be outputted as a PDF


That leaves me with the problem of opening the Excel file on Linux. That's the toughest part all along  :(


Duh, now I look stoopid too!  Sorry Neo...
Logged
VGR
Mentor

Offline Offline

Posts: 682



WWW
« Reply #14 on: February 11, 2006, 11:46:43 AM »

ok, then I can come into play ;-)

I had the very same problem and thought "trivially, he is on Windows" so I let others help you ;-)

I had once to write an eXcel reader in BINARY format. May-be you can follow this track ? It's not ***that*** difficult to decrypt this proprietary format, a lot of documentation is on the web. The simpliest solution is the OpenOffice one mentioned above, though.

good luck
Logged

techie overlord, answers all kind of questions on http://www.europeanexperts.org
Pages: [1]
« previous next »
    Jump to: